DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23939>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23939 document('relative-URI') seems to resolve wrongly depending on request-URI (SourceResolver?) Summary: document('relative-URI') seems to resolve wrongly depending on request-URI (SourceResolver?) Product: Cocoon 2 Version: 2.1.2 Platform: PC URL: http://www.huttar.net/lars- kathy/test/cocoon/gem/transforms/framework.xsl OS/Version: Windows XP Status: NEW Severity: Normal Priority: Other Component: sitemap components AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I have a stylesheet, used in a Cocoon pipeline, that references document('a-literal-relative-URI'): <xsl:template match="/dir:directory"> <xsl:value-of select="count(document('../resources/gem-data.xml'))" /> ... The XSLT spec says the URI should be resolved against the base URI of the stylesheet (since the literal relative URI is found in the stylesheet itself, not the input document). This wasn't working; document() returned nothing, even though the file existed. Then I discovered that when I edited the sitemap to change the request-URI pattern so that it didn't end in "/", the stylesheet started working! Why should a change in the request-URI affect how a relative URI in document() is resolved with respect to the base URI of the stylesheet? I asked this question on Cocoon users list, and J. Pietschmann suggested it might be a problem with the Cocoon SourceResolver: "No, it means the Cocoon source resolver didn't remove the last component of the base URL and therefore resolved your URL wrong. Look into the code for details." I will append two of my posts here; they give URLs to example documents and explain some details. Hi all, I am trying to access an auxiliary XML document from an XSLT stylesheet, using the document() function, within a Cocoon pipeline. E.g. <xsl:template match="/dir:directory"> <xsl:value-of select="count(document('../resources/gem-data.xml'))" /> ... The XSLT Programmer's Ref. (Kay) says that relative URI there should be resolved relative to the directory where the stylesheet is located (since the string argument to document() comes from the stylesheet, not from the source file). Does that hold true in Cocoon? I would think so, but... In the above example, the count() expression is returning zero. The stylesheet is cocoon/gem/transforms/framework.xsl, while the XML document is cocoon/gem/resources/gem-data.xml. I ran the same stylesheet from outside of Cocoon, using Saxon, and the count() expression returned 1! (using gem/resources/testdir.xml as input.) (I tried this both from the cocoon/gem/transforms directory, and from the cocoon/gem directory, in case it mattered.) So it sounds like the stylesheet is misbehaving within Cocoon. As an additional test, I ran this simpler stylesheet both within and outside cocoon: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gem="http://www.sil.org/namespace/gem"> <xsl:template match="/"> <xsl:value-of select="count(document('../resources/gem-data.xml'))" /> </xsl:template> </xsl:stylesheet> And in this case, count() returned 1 both within Cocoon and outside it! This simpler stylesheet, test-docmt.xsl, was also located in cocoon/gem/transforms. So this simpler stylesheet behaves correctly inside and outside of Cocoon! So I'm confused. I'm using Cocoon 2.1.2. I've put the aforementioned files (and the cocoon/ and gem/ sitemaps) at http://www.huttar.net/lars-kathy/test/cocoon/gem/... in case anyone is kind enough to look at them. [Specifically: cocoon/sitemap.xmap cocoon/gem/sitemap.xmap cocoon/gem/archframe/r1 (empty directory) cocoon/gem/resources/gem-data.xml cocoon/gem/resources/testdir.xml cocoon/gem/transforms/framework.xsl cocoon/gem/transforms/test-docmt.xsl ] Thanks, Lars Hi folks, I just found how to make my problem go away... I had had the gem sitemap configured to match the URI "*/*/framework/" and thus dispatch my framework.xsl stylesheet. Now I changed that to "*/*/framework", i.e. removed the trailing "/", and now it works (the document() function is finding the XML file ../resources/gem-data.xml). Weird! I'm still trying to figure out what that means. Any pointers? Does it mean Xalan is a nonconformant XSL processor? Or would someone claim it's correct for the document() function to base its URI on the request URI?? Thanks, Lars
