Re: [xslt] Using XSLT as a query engine



On Fri, Mar 22, 2002 at 09:05:45AM -0800, Dave Guerrieri wrote:
> 
> 
> I have created a large XML File (2.6 MB) and would like to query it to find the
> element with a particular attribute.  The attribute is unique in the file.  I
> have also created the following XSLT file:
> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
> <xsl:param name="param1"/>
> <xsl:param name="param2"/>
> 
> <xsl:key name="Id-key" match="/DocRoot/Element" use="@id"/>
> <xsl:template match="/">
>    <xsl:copy-of select="key('Id-key',$param1)"/>
>    <xsl:copy-of select="key('Id-key',$param2)"/>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> I have two questions:
> 
> 1) I must be misunderstanding how to use xsl:copy-of because only the element
> with the id attribute matching $param1 is output.

  you're generating a multi-rooted tree, libxml possbly only output
the first or something like that.
  Use --debug and -v options of xsltproc to see what happen

> 2)Can I tell libxslt to build the key only once so I can apply the stylesheet
> with new parameters and not have to take the performance hit to rebuild the key
> for an unchanged document?

  Hum, not with the usual interfaces, there will be a bit of assembly required
like defining your own modified version of xsltApplyStylesheetInternal()

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]