xsl-list
[Top] [All Lists]

Multi-part search XPath expressions.

2004-09-10 17:36:37
I'm fairly new to XSLT and am currently working my way though the
excellent "XSLT Programmer's Reference", various on-line tutorials and
FAQs. I'm really struggling to write the XPath expressions I want and
suspect the problem is I'm not thinking right. I'm coming to XPath
with a database background, oriented, and goals. As an example, here
is a fragment of an XML file I'm working with:


<Australian_Birds>
        <Species>
                <Sequence>1</Sequence>
                <Family_Name>Struthionidae</Family_Name>
                <Genus_Name>Struthio</Genus_Name>
                <Species_Name>camelus</Species_Name>
                <Common_Name>Ostrich</Common_Name>
                <Extinct>False</Extinct>
        </Species>
        <Species>
                <Sequence>2</Sequence>
                <Family_Name>Casuariidae</Family_Name>
                <Genus_Name>Casuarius</Genus_Name>
                <Species_Name>casuarius</Species_Name>
                <Common_Name>Southern Cassowary</Common_Name>
                <Extinct>False</Extinct>
        </Species>
</Australian_Birds>

(The orginal file has over 800 birds and comes in at around 200K of
text.) I want to do searches, such as

     select species where the Extinct="True" and Genus_Name="Alectura"

The best I've been able to come up with is an expression like the one below:

   
/Australian_Birds/Species[Extinct!="True"]/self::Species[Genus_Name="Alectura"]

Is this actually correct? It seems a bit cumbersome.

I've got a lot of related questions having to do with how to,
more-or-less, "search" XML documents using XSLT. I've been trying to
find a tutorial with explicit example expressions but haven't found
one yet. If I've missed something in Kay or on-line, please feel free
to point me in the right direction.

Much appreciated,



-- 
---------------------------------------------
 David Adams
  dpadams(_at_)gmail(_dot_)com
 Bermagui 2546 NSW
---------------------------------------------