xsl transformar template partir online generate from example crear convertir c# .net xslt xsl-fo

c# - transformar - xslt editor



crear hipervínculos dinámicamente al transformar xml a xsl-fo usando xlst? (1)

Quiero crear un encabezado en mi informe PDF usando mi archivo xsl. Si el archivo de origen contiene un hipervínculo, entonces debería representarlo como hipervínculo, de lo contrario como texto sin formato.

Por ejemplo, mi xml se ve así:

<a href=''http://google.com'' target=''_blank''>This is the heading </a>"

Debería mostrar un hipervínculo si hay uno, de lo contrario, mostrar el encabezado como texto sin formato. ¿Cómo puedo hacer eso?

No puedo usar el siguiente código debajo de la etiqueta de otra manera, ve abajo

<xsl:choose> <xsl:when test="($RTL=''true'') or ($RTL=''True'')"> <fo:block wrap-option="wrap" hyphenate="true" text-align="right" font-weight="bold"> <xsl:value-of select="@friendlyname" /> </fo:block> </xsl:when> <xsl:otherwise> <!--<fo:block wrap-option="wrap" hyphenate="true" font-weight="bold">--> <xsl:template match="a"> <fo:block> <xsl:choose> <xsl:when test="@href"> <fo:basic-link> <xsl:attribute name="external-destination"> <xsl:value-of select="@href"/> </xsl:attribute> <xsl:value-of select="@friendlyname" /> </fo:basic-link> </xsl:when> <xsl:otherwise> <xsl:value-of select="@friendlyname" /> </xsl:otherwise> </xsl:choose> </fo:block> </xsl:template> <!--<xsl:value-of select="@friendlyname" />--> <!--</fo:block>--> </xsl:otherwise> </xsl:choose> </xsl:if>

¿Cómo puedo usarlo allí?


Para mostrar un enlace en XSL-FO, use fo:basic-link . Vea la parte relevante de la especificación para más detalles.

Esto crea un enlace simple y seleccionable sin ningún tipo de formato. Es decir, el formato se hereda del elemento de bloque circundante. Entonces, si sus enlaces deben ser subrayados o mostrados en azul, debe especificar esto explícitamente. Por ejemplo, al usar un elemento fo:inline .

Ahora, en términos del código XSLT, si encuentras elementos:

<xsl:template match="a"> <fo:block><!--This is the heading block-->

Pruebe si hay un atributo href o no:

<xsl:choose> <xsl:when test="@href"> <fo:basic-link> <xsl:attribute name="external-destination"> <xsl:value-of select="@href"/> </xsl:attribute> <xsl:value-of select="."/> </fo:basic-link> </xsl:when>

Por otro lado, si no existe tal atributo:

<xsl:otherwise> <xsl:value-of select="."/> </xsl:otherwise> </xsl:choose> </fo:block> </xsl:template>

Los enlaces básicos pueden tener un destino externo o interno. Este último se utiliza para referirse a capítulos específicos de la tabla de contenidos, por ejemplo.