Re: [xsl] XPath equivalent of a join

Subject: Re: [xsl] XPath equivalent of a join
From: "Aaron Luke" <bluenike@xxxxxxxxx>
Date: Sat, 14 Jul 2007 01:53:13 -1000
BTW, if instead of 1501 classes x 1501 teacher, there are 1501 classes
x 1 teacher or 1 class x 1500 teachers, the running times are only 1
second and 3 seconds respectively.

On 7/14/07, Aaron Luke <bluenike@xxxxxxxxx> wrote:
Hi-

Thanks for your solution... the only problem is that this solution
seems to run very slowly.
If I replicate 1500 copies of the class with id="2" and 1500 with the
teacher with id="9",
then the query takes almost 30 seconds using Saxon8 on a 2Ghz Core 2
Duo even though
the query only matches 1 record.  Any ideas on speeding that up?

I included a fixed version of the xml doc below, too.

Aaron

  <root>
     <class id="1">
           <teacher>5</teacher>
         </class>
     <class id="2">
           <teacher>9</teacher>
         </class>

     <teacher id="5">
           <gender>female</gender>
         </teacher>
     <teacher id="9">
           <gender>male</gender>
         </teacher>
  </root>



On 7/14/07, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:
> Your input XML is not as per the XML spec (there should be double
> quotes around attribute values).
>
> If the above error is corrected in the XML, I found the following
> solution to work:
>
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version="1.0">
>
>   <xsl:output method="xml" indent="yes" />
>
>   <xsl:template match="/root">
>     <result>
>       <xsl:copy-of select="class[teacher = ../teacher[gender =
> 'female']/@id]" />
>     </result>
>   </xsl:template>
>
> </xsl:stylesheet>
>
> On 7/14/07, Aaron Luke <bluenike@xxxxxxxxx> wrote:
> > Hi all-
> >
> > Given the following document:
> >
> > <root>
> >  <class id="1">
> >    <teacher>5</teacher>
> >  </class>
> >  <class id="2">
> >    <teacher>9</teacher>
> >  </class>
> >
> >  <teacher id=5>
> >    <gender>female</gender>
> >  </teacher>
> >  <teacher id=9>
> >    <gender>male</gender>
> >  </teacher>
> > </root>
> >
> > Is there an XPath statement that selects all of the classes taught by
> > female teachers (in this case, just the first class)?
> > The field class.teacher is an id reference to teacher.id.
> >
> > In sql, I would be looking for:
> >
> > select class.* from class c, teacher t where c.teacher=t.id and
> > t.gender='female';
> >
> > Can't seem to figure this one out- any help would be appreciated.
> >
> > Aaron
>
>
> --
> Regards,
> Mukul Gandhi

Current Thread