[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Referring to stylesheet itself, possible in XSLT 1

Subject: Re: Referring to stylesheet itself, possible in XSLT 1.0, but how in XSLT 2.0?
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 17 Oct 2006 13:44:30 +0200
document uri xsl
Michael Kay wrote:
I understand, but it really just said "Transformation failed". Without any descriptive error, warning or whatever.
That's a bit puzzling. Calling document() with a URI that doesn't exist is a
recoverable error.

It was puzzling me too. I use Oxygen's Eclipse plugin for testing the XSLT. Normally it simply lists all the errors. Now it just said "Transformation failed". I learned something: try it outside of the IDE box. The following happens:


With this stylesheet:
---------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
1) <xsl:value-of select="document-uri(document(''))"></xsl:value-of>
2) <xsl:value-of select="static-base-uri()"></xsl:value-of>
3) <xsl:value-of select="base-uri(.)"></xsl:value-of>
</xsl:template>
</xsl:stylesheet>


This output:
------------
<?xml version="1.0" encoding="UTF-8"?>
       1) file:/D:/Workspaces/Eclipse/etc/def/config/test.xslt
       2) file:/D:/Workspaces/Eclipse/ect/def/config/test.xslt
       3) file:/D:/Workspaces/Eclipse/etc/def/config/test.xml


With this stylesheet: --------------------- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xml:base="../.."> <xsl:template match="/"> 1) <xsl:value-of select="document-uri(document(''))"></xsl:value-of> 2) <xsl:value-of select="static-base-uri()"></xsl:value-of> 3) <xsl:value-of select="base-uri(.)"></xsl:value-of> </xsl:template> </xsl:stylesheet>

This output:
------------
Error on line 1 column 1 of file:/D:/Workspaces/Eclipse/etc/:
SXXP0003: Error reported by XML parser: Content is not allowed in prolog.
Recoverable error on line 5 of file:/D:/Workspaces/Eclipse/etc/def/config/test.xslt:
FODC0005: org.xml.sax.SAXParseException: Content is not allowed in prolog.
<?xml version="1.0" encoding="UTF-8"?>
1)
2) file:/D:/Workspaces/Eclipse/etc/
3) file:/D:/Workspaces/Eclipse/etc/test.xml




I believe in the light of what all people said on this subject, this behavior is to be expected.

Try putting xml:base at the level of the stylesheet where you need it, e.g.
on a template rule, and have a global variable

The xml:base was used to make xsl:import easier. I did not want to add it to each xsl:import statement. But I guess, I'd have to decide on the pros and cons of either technique. At least I understand now what's happening.


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.