xsl-list
[Top] [All Lists]

RE: Accessing a node dynamically using XSL

2006-01-16 09:00:50
In XSLT 2.0 you want to do something like:

<xsl:for-each select="
    for $name in tokenize(Subjects, ',\s*')
    return *[name() = $name]">
  ...
</xsl:for-each>

Tokenizing a string is a bit more difficult in 1.0, but you can use
str:tokenize() in EXSLT.

Michael Kay
http://www.saxonica.com/

-----Original Message-----
From: Sumiit Kumar Mukherjee 
[mailto:sumit(_dot_)mukherjee(_at_)gmail(_dot_)com] 
Sent: 16 January 2006 15:52
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Accessing a node dynamically using XSL

I have an XML which is of the format:

<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 [in this case, Literature and
Fiction]. I need to get the values for each of these elements in turn.
How can this be done in XSL? In short, I am looking for a dynamic way
of accessing elements based on the XML itself. I require this because
I have not idea about the values that might be present under the
<Subjects> element.

Thanks

--~------------------------------------------------------------------
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>
--~--





--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>