Sumiit Kumar Mukherjee wrote:
<Name type="String">harry</Name>
<Subjects type="String">Literature,Fiction</Subjects>
<Literature type="String">Shakespeare, Woodsworth, Jeffrey
Archer</Literature>
<Fiction type="String">Da Vinci Code</Fiction>
My requirement is like this: First, find out the values in the
<Subjects> element. For each such value [separated by a comma],
there will be an element present in the XML
~> cat skm.xml
<root>
<Name type="String">harry</Name>
<Subjects type="String">Literature,Fiction</Subjects>
<Literature type="String">Shakespeare, Woodsworth</Literature>
<Fiction type="String">Da Vinci Code</Fiction>
</root>
~> cat skm.xsl
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="text"/>
<xsl:template match="root">
<xsl:apply-templates
select="for $sub in tokenize(Subjects, ', *')
return *[local-name()=$sub]"/>
</xsl:template>
<xsl:template match="*">
<xsl:value-of select="local-name()"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="."/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:transform>
~> saxon skm.xml skm.xsl
Literature: Shakespeare, Woodsworth
Fiction: Da Vinci Code
With XSLT 1.0, use a recursive template instead of an XPath 'for'
expression.
--drkm
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs
exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--