1 / 3

Using XSLT and XPath to Transform XML Documents into Text Files

Using XSLT and XPath to Transform XML Documents into Text Files. Roger L. Costello XML Technologies. Problem. Create a stylesheet that creates a text file containing each member's data. Line for each member Member data separated by a slash delimiter. Jeff/555-1234/555-4321/lightgrey

keaira
Download Presentation

Using XSLT and XPath to Transform XML Documents into Text Files

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using XSLT and XPath to Transform XML Documents into Text Files Roger L. Costello XML Technologies

  2. Problem • Create a stylesheet that creates a text file containing each member's data. • Line for each member • Member data separated by a slash delimiter Jeff/555-1234/555-4321/lightgrey David/383-1234/383-4321/lightblue Roger/888-1234/888-4321/lightyellow

  3. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="text"/> <xsl:variable name="delimiter" select="'/'"/> <xsl:template match="FitnessCenter"> <xsl:for-each select="Member"> <xsl:apply-templates select="."/> <xsl:text>&#xD;&#xA;</xsl:text> <!-- Hex value for carriage return --> </xsl:for-each> </xsl:template> <xsl:template match="Member"> <xsl:for-each select="*[position() &lt; last()]"> <xsl:value-of select="."/> <xsl:value-of select="$delimiter"/> </xsl:for-each> <xsl:value-of select="*[last()]"/> </xsl:template> </xsl:stylesheet> (see text-example01)

More Related