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=""; 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 Veillard      | Red Hat Network  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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