[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Identifying two tags that share some attribute nam

Subject: Re: Identifying two tags that share some attribute names and values
From: Zack Brown <zbrown@xxxxxxxxxxxxxxx>
Date: Sat, 4 May 2002 14:00:20 -0700
Re:  Identifying two tags that share some attribute nam
On Sat, May 04, 2002 at 09:18:45PM +0200, Joerg Heinicke wrote:
> Hello Zack,
> 
> I have a solution, but I don't know whether it's the optimum.

That was fast!

> I didn't 
> get it with one expression and need the step with $test:
> 
> <xsl:variable name="file1" select="/"/>
> <xsl:variable name="file2" select="document('2.xml')/outsidedata"/>
> 
> <xsl:template match="/">
>     <xsl:apply-templates select="$file2/b"/>

That's a problem, because 2.xml may contain thousands of entries, and I
don't want to process each one. I just want to process the <a> from 1.xml
and find any corresponding <b> in 2.xml.

> </xsl:template>
> 
> <xsl:template match="b">
>     <xsl:variable name="test">
>         <xsl:for-each select="@*">
>             <xsl:if test="$file1/a/@*[name()=name(current())][. != 
> current()] or not($file1/a/@*[name()=name(current())])">
>                 <xsl:text>false</xsl:text>
>             </xsl:if>
>         </xsl:for-each>
>     </xsl:variable>

Nice hack! Even aside from the cool middle part, I like the idea of looping
within a variable creation, in order to include a specific result that can
be tested for later.

>     <xsl:if test="not(contains($test, 'false'))">
>         <xsl:text>[</xsl:text>
>         <xsl:value-of select="."/>
>         <xsl:text>]</xsl:text>
>     </xsl:if>
> </xsl:template>
> 
> I test on every attribute whether it is in <a> and has a different value 
> or it does completely not exist. If it is so I add a false to the 
> test-string. If no 'false' is contained in $test, the value of b will be 
> copied to the output.
> 
> Regards,
> 
> Joerg
> 

-- 
Zack Brown

 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.