[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Checking for existence of a string within node-set
The way that I'd do this is to load up the second document into a global variable: <xsl:variable name="xml2" select="document(xml2.xml)"/> And then in your template for BBB do the following <xsl:template match="BBB"> <xsl:if test="$xml2/MMM/NNN/OOO[@name=current()/@name and (@mode=1 or @mode=2)]"> <!-- do processing here --> </xsl:if> </xsl:template> HTH! Dion -----Original Message----- From: Manny Parasirakis [mailto:mannyp@xxxxxxx] Sent: Thursday, April 25, 2002 2:42 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Checking for existence of a string within node-set 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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|