How to Change the Text Node for XML in an XSL
The Extensible Stylesheet Language (XSL) developed by W3C provides a means for transforming, navigating and formatting XML documents. XSLT is the XSL portion used for transforming XML document node content, such as titles and text, using match rules. XSLT generates text as a default when processing the rule for the text ancestor element. Use the “text()” operator to specifically match and change XML text nodes.
Instructions
-
-
1
Open your XML stylesheet.
-
2
Type the following in the location where you want to modify the text node:
<xsl:template match="text()">
<i><xsl:value-of select="."/></i>
</xsl:template>This rule will italicize all text.
-
-
3
Save the stylesheet with an “.xsl” extension, for instance, “myxslt.xsl.”
-
4
Type the a reference to the stylesheet into your XML document beneath the XML version line:
<?xml-stylesheet type="text/xsl" href="myxslt.xsl"?> -
5
Open the XML document that references the stylesheet using a Web browser to test the result of your changes.
-
1
References
Resources
- Photo Credit Comstock/Comstock/Getty Images