I have an XML file with information, for example:
<letter>
<name>Test</name>
<age>20</age>
<me>Me</me>
</letter>
And then I have an text template like:
Dear $name,
some text with other variables like $age or $name again
greatings $me
When using xslt to transform the XML to the plain text letter I can use something like:
<xsl:text>Dear </xsl:text><xsl:value-of select="name"/><xsl:text>
some text with other variables like </xsl:text>
<xsl:value-of select="age"/><xsl:text> or </xsl:text>
<xsl:value-of select="name"/><xsl:text> again
greatings </xsl:text><xsl:value-of select="me"/>
But when I get more and more variables and more text this becomes a nightmare to enter and to maintain.
Is there some way to do this in a cleaner way using xslt? I would prefer if I could just use the text template I used as an example above and have $name and $age replaced with the correct values.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…