Subject: Re: [xsl] Identifying two tags that share some attribute names and values From: Zack Brown <zbrown@xxxxxxxxxxxxxxx> Date: Sat, 4 May 2002 14:00:20 -0700 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Identifying two tags that, Joerg Heinicke | Thread | Re: [xsl] Identifying two tags that, Jeni Tennison |
Re: [xsl] Identifying two tags that, Joerg Heinicke | Date | [xsl] Finding the lowest 'price' el, tinku |
Month |