Re: [xslt] Parsing bug? Or user not fully spec compliant?



On Thu, Nov 08, 2001 at 11:18:06AM -0800, Lars Kellogg-Stedman wrote:
> I'm following a fairly well trod path by trying to generate HTML from
> XML via xsltproc.  Unfortunately, I've run into a difference in
> behavior between xsltproc and 4xslt (the xslt processor from 4suite). 
> Given the following xml source:
>   <foo:document xmlns:foo='http://foo/'
>         xmlns='http://www.w3.org/TR/xhtml1/strict'>
[...]
>                 <h2>How much would would a wood chuck chuck?</h2>
[...]
>   <xsl:template match="h2">
>         <h2><xsl:value-of select="."/></h2>
>   </xsl:template>
[...]
> And this is what I get with 4xslt.  However, if I try to parse this
> with xsltproc, the verbose output says:
> 
>   xsltProcessOneNode: no template found for h2
[...]
> In other words, the <h2> element is not matching the h2 template when
> the document is processed with xsltproc.  Is this a bug in the
> xsltproc?  Or is my stylesheet malformed?

  4xslt is bugged.
  h2 is in a namespace (http://www.w3.org/TR/xhtml1/strict)

The "h2" XPath expression will only match element of name h2 which have
no namespace.
http://www.w3.org/TR/xpath
Section 2.3
----------
A node test that is a QName is true if and only if the type of the node
(see [5 Data Model]) is the principal node type and has an expanded-name
equal to the expanded-name specified by the QName.
----------
 The expanded name of the element in the document is
   {http://www.w3.org/TR/xhtml1/strict}:h2
 the one for the match is
   null:h2

 Fix that by defining a prefix in your stylesheet associated to 
 http://www.w3.org/TR/xhtml1/strict and add the prefix to the match.

  And don't forget to report the bug to 4suite,

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]