Re: [xslt] document() Function and Fragment Identifiers

Mark Gannon schrieb am 21.11.2010 um 16:01 (-0800):
> I'm working on an xsl implementation that requires retrieving
> documents over the network using fragment identifiers.  By fragment
> identifiers I mean URLs that look like: 
> In this example everything after the "#" is the identifier for a node
> (e.g. an attribute where id="moregood").  From reading the
> documentation for libxslt and xsl (Tidwell's book) my understanding is
> that this should return the node with the "moregood" id and any
> children the node might have.
> Is this an accurate understanding of how this should work?

Yes. But note that it doesn't work in all processors. Yes in LibXSLT and
Saxon, no in Xalan 2.7.1 and MSXML 6.0.

> If my understanding of how fragment identifiers should work is
> accurate, the following example is returning a null or empty set for a
> URL when using a fragment ID when I would expect to get a node set
> based on the id: 

What you appear to have yet to discover is that ID-ness in this case
is conferred upon element nodes in the document by virtue of their
carrying an attribute of type ID as per the *DTD*.

Here's a sample I have to demonstrate this:

          (o o)
------oOOo-(_)-oOOo------           id-function.xml
<!DOCTYPE Urmel[
<!ELEMENT Urmel (Elm*,Schelm*)>
  <Elm AB="Erwin"/>
  <Elm AB="Egon"/>
  <Elm AB="Eberhard"/>
  <Elm AB="Eduard"/>
  <Elm AB="Edmund"/>
  <Elm AB="Ewald">
  <Schelm ab="Erwin Egon Eberhard"/>
  <Schelm ab="Egon"/>
  <Schelm ab="Ewald Erwin"/>

-------------------------           id-function.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
  <xsl:strip-space elements="*"/>
  <xsl:output indent="yes"/>

  <xsl:template match="/">
        <xsl:apply-templates select="*/Schelm"/>
        <xsl:copy-of select="document('id-function.xml#Ewald')"/>

  <xsl:template match="Schelm">
      <xsl:copy-of select="id(@ab)"/>

Michael Ludwig

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