[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

Subject: RE: Checking for existence of a string within node-set
From: "Dion Houston" <dionh@xxxxxxxxxxxxx>
Date: Thu, 25 Apr 2002 15:04:51 -0700
xsl node existence
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.