This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Identifying two tags that share some attribute names and values


On Sun, May 05, 2002 at 12:06:36PM +0200, Joerg.Heinicke@gmx.de wrote:
> > 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.
> 
> Hi Zack,
> 
> I can't imagine, that this is possible. Maybe with creating a Result Tree
> Fragment (RTF), but then you need a processor specific extension function,
> which transforms the RTF back to a nodeset. But maybe other people have better
> ideas than me.

I didn't mean I didn't want to process each entry. I meant that the
intended output will be coming from the <a>s in 1.xml, not the <b>s in
2.xml. I want to process each <a> so it gives the proper output within
the structure of the rest of the document. It looks like the solution
you gave will process all the <b>s independently of the document I'm
trying to produce.

1.xml may have data like this:

---------------------------- 1.xml data ---------------------------------
<p>The quick brown <a x="1" y="2" z="3">fox</a> jumps over the lazy
<a x="5" y="10" z="15">dog</a>.</p>
-------------------------------------------------------------------------

I want to transform those <a> tags into something that will be inserted
there in the text.

Am I just missing it? Is that what you're recipe does?

Be well,
Zack

> 
> Joerg
> 
> 
> 
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> > 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.
> 
> -- 
> GMX - Die Kommunikationsplattform im Internet.
> http://www.gmx.net
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

-- 
Zack Brown

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]