Hi all, I have been trying to set up a XSLT script to process a XML input conditionally, and I am stuck...
I just need it to be able to process the XML input conditionally and return an output in XML format.
That is, within the XML input, there are multiple sets of node (I am always confused about how to describe them correctly...), and the script is going to check each set of node for a particular element (ex. a certain types of sport). If the node does contain a particular element, then certain elements of that node will be extract and output. Otherwise, that node will not be output at all.
--------
(input.xml)
(output.xml)
--------
I have tried to use <xsl:if> or <xsl:choose> to filter out just the wanted informations, but it didn't work the way I wanted.
One of the problems I have with the output, is that instead of output in the format that I mentioned above, it outputs like (assume there are three member nodes that contain a matched elements, and are being output):
(output)
Can anyone give me an insight? (It doesn't have be an example script, just point out what kind of possible scripting error I might have that generates the above output)
Thank you.
I just need it to be able to process the XML input conditionally and return an output in XML format.
That is, within the XML input, there are multiple sets of node (I am always confused about how to describe them correctly...), and the script is going to check each set of node for a particular element (ex. a certain types of sport). If the node does contain a particular element, then certain elements of that node will be extract and output. Otherwise, that node will not be output at all.
--------
(input.xml)
Code:
<root_node>
- <member id="100">
- <contact_info>
- <name>
<full_name>joe smith</full_name>
+ <address>
+ <phone>
</contact_info>
- <hobby num="0">
<sport>baseball</sport>
</hobby>
- <hobby num="1">
<sport>football</sport>
</hobby>
.
.
.
+ <hobby num="n">
</member>
+ <member id="101">
+ <member id="102">
.
.
.
+ <member id="n">
</root_node>
(output.xml)
Code:
<root>
- <member>
.
.
.
(member 1's full name)
(member 1's sport that matched the criteria)
.
.
.
</member>
- <member>
.
.
.
(member 1's full name)
(member 1's sport that matched the criteria)
.
.
.
</member>
.
.
.
+ <member num="n">
</root>
I have tried to use <xsl:if> or <xsl:choose> to filter out just the wanted informations, but it didn't work the way I wanted.
One of the problems I have with the output, is that instead of output in the format that I mentioned above, it outputs like (assume there are three member nodes that contain a matched elements, and are being output):
(output)
Code:
- <member>
<member 1's full name>some name</member 1's full name>
<member 2's full name>some name</member 1's full name>
<member 3's full name>some name</member 1's full name>
<member 1's matched sport>some sport</member 1's matched sport>
<member 2's matched sport>some sport</member 1's matched sport>
<member 3's matched sport>some sport</member 1's matched sport>
</member>
Can anyone give me an insight? (It doesn't have be an example script, just point out what kind of possible scripting error I might have that generates the above output)
Thank you.