[Home] [By Thread] [By Date] [Recent Entries]
Does anyone know of any way to check for the existence of a string within
an attribute inside a node within a node-set? I am trying to transform an
XML file by only selecting the tags whose name attribute matches the name
attribute in another xml file's tag. Example:
xml1.xml <AAA>
<BBB name="xxx">
<CCC>...</CCC>
</BBB>
<BBB name="yyy">
<CCC>...</CCC>
</BBB>
<BBB name="zzz">
<CCC>...</CCC>
</BBB>
</AAA>xml2.xml <MMM>
<NNN>
<OOO name="xxx" mode="1"/>
<OOO name="yyy" mode="2"/>
<OOO name="zzz" mode="3"/>
</NNN>
</MMM>I am transforming xml1.xml using information within the attributes in xml2.xml. I would like the output to look like this: <AAA>
<BBB name="yyy">
<CCC>...</CCC>
<DDD>...</DDD> <--- This would be added by the transform
<EEE>...</EEE> <--- This would be added by the transform
</BBB>
<BBB name="zzz">
<CCC>...</CCC>
<DDD>...</DDD> <--- This would be added by the transform
<EEE>...</EEE> <--- This would be added by the transform
</BBB>
</AAA>Basically what is happening is that the BBB tag would only be included if its name attribute exists in xml2.xml within the OOO name attribute and the mode attribute is 1 or 2. In addition, during the transform I would like to add the DDD and EEE tags within each BBB tag. I tried using xsl:foreach within another xsl:foreach to iterate through each name attribute within xml2.xml and then using an xsl:if to check if the strings match. Within the if I use an xsl:copy which adds the DDD and EEE tag but then closes the BBB tag and writes the CCC tag outside of the BBB. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|

Cart



