I have a problem with getting the correct result for my xsl transformation. When I am exporting my xml document from Indesign, without any transformation, following code is generated:
<text>aerher<b>hea</b>rh er<i>haeh</i> rehe eageag</text>
it should however look like this:
<text value="aerher[b]hea[/b]rh er[i]haeh[/i] rehe eageag" />
Notice also, how <b>
is transforming to [b]
. Now my biggest problem is, that I am not even getting all of my text selected. With the following transformation, my result looks like this:
<xsl:template match="text">
<text value="{text()}"/>
</xsl:template>
<text value="aerher"/>
How can I get the complete text including my Tags? I will find out myself how to transform <b>
to [b]
. I just can't figure out, why it is not selecting all of my text?
<b>
is not part of the text node(s) contained by the <text>
element - it is markup . If you want to convert the markup to text (ie pseudo-markup), try something like:
<xsl:template match="text">
<xsl:copy>
<xsl:attribute name="value">
<xsl:apply-templates/>
</xsl:attribute>
</xsl:copy>
</xsl:template>
<xsl:template match="b">
<xsl:text>[b]</xsl:text>
<xsl:apply-templates/>
<xsl:text>[/b]</xsl:text>
</xsl:template>
<xsl:template match="i">
<xsl:text>[i]</xsl:text>
<xsl:apply-templates/>
<xsl:text>[/i]</xsl:text>
</xsl:template>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.