delimiter or tokenizer in xslt
-
XML
<?xml version="1.0" encoding="UTF-8"?>
<!-- Edited by XMLSpy -->
<catalog>
<example>
:20:FT13261793408907
N23B:CRED
SA32A:130918USD111670,00
</example>
</catalog>
XSLT<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/"><xsl:for-each select="catalog"> <tr> <td><xsl:value-of select="example"> </td> </tr> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Current OUTPUT
:20:FT13261793408907 N23B:CRED SA32A:130918USD111670,00
Desired OUTPUT
:20:FT13261793408907
N23B:CRED
SA32A:130918USD111670,00
output must not be in a same line its must be as shown in the desired o/p -
XML
<?xml version="1.0" encoding="UTF-8"?>
<!-- Edited by XMLSpy -->
<catalog>
<example>
:20:FT13261793408907
N23B:CRED
SA32A:130918USD111670,00
</example>
</catalog>
XSLT<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/"><xsl:for-each select="catalog"> <tr> <td><xsl:value-of select="example"> </td> </tr> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Current OUTPUT
:20:FT13261793408907 N23B:CRED SA32A:130918USD111670,00
Desired OUTPUT
:20:FT13261793408907
N23B:CRED
SA32A:130918USD111670,00
output must not be in a same line its must be as shown in the desired o/pYou don't mention if there can be one or more example nodes within each catalog node. This code works if there are many catalog's with one example node.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"<xsl:output method="text" indent="no"/>
<xsl:template match="catalog">
<xsl:value-of select="example"/>
</xsl:template></xsl:stylesheet>
And this code works if there are many catalog nodes and many example nodes.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"<xsl:output method="text" indent="no"/>
<xsl:template match="catalog">
<xsl:apply-templates select="example" />
</xsl:template><xsl:template match="example">
<xsl:value-of select="node()"/>
</xsl:template></xsl:stylesheet>
XSLT is recursive by nature, so no need for the loop. If you want text output, I don't understand the HTML tags in your example code.