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

Re: Global namespace prefixes (Corrected Examples)

Subject: Re: Global namespace prefixes (Corrected Examples)
From: Nathan Potter <ndp@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Nov 2008 22:14:34 -0800
Re:  Global namespace prefixes (Corrected Examples)
I wored out the XSLT Extension stuff, so Now my test transform looks like this:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:exslt="http://exslt.org/common"
xmlns:dap="http://xml.opendap.org/ns/DAP/3.2#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<xsl:output method='xml' version='1.0' encoding='UTF-8' indent='yes'/>


<xsl:variable name="dummy">
<xsl:element name="att:dummy" namespace="{/dap:Dataset/@base}/ att#"/>
</xsl:variable>



<xsl:template match="dap:Dataset" >
<rdf:RDF>
<xsl:copy-of select="exslt:node-set($dummy)// namespace::*"/>
<xsl:apply-templates />
</rdf:RDF>


</xsl:template>

<xsl:template match="dap:Attribute" >
<xsl:element name="{@name}" namespace="{/dap:Dataset/@base}/ att#"><xsl:value-of select="." /></xsl:element>
</xsl:template>



</xsl:stylesheet>




And I get this error:


ERROR: 'com.sun.org.apache.xalan.internal.xsltc.TransletException: org.jdom.IllegalAddException: The namespace xmlns="http://base.document/att# " could not be added as a namespace to "rdf:RDF": The namespace prefix "" collides with an additional namespace declared by the element'
org.jdom.transform.XSLTransformException: Could not perform transformation: com.sun.org.apache.xalan.internal.xsltc.TransletException: com.sun.org.apache.xalan.internal.xsltc.TransletException: org.jdom.IllegalAddException: The namespace xmlns="http://base.document/att# " could not be added as a namespace to "rdf:RDF": The namespace prefix "" collides with an additional namespace declared by the element



Which seemed odd until I dump out my dummy element:


<xsl:copy-of select="$dummy"/>

Which produces:

<dummy xmlns="http://base.document/att#" />



So despite the fact that I assigned a namespace prefix when I created $dummy, the XSLT processor appears to ignore it.



Nathan


On Nov 13, 2008, at 5:25 PM, Nathan Potter wrote:

I don't understand how to do this thing with node-set. When I try this:



<xsl:variable name="dummy">
<xsl:element name="att:dummy" namespace="{/dap:Dataset/@base}/ att#"/>
</xsl:variable>



<xsl:template match="dap:Dataset" >
<rdf:RDF>
<xsl:copy-of select="exslt:node-set($dummy)// namespace::*"/>
<xsl:apply-templates />
</rdf:RDF>
</xsl:template>


I get a "Namespace prefix 'exslt' is undeclared." error when I compile the stylesheet. Which isn't surprising, since it is missing and I suspect the crux of this trick is in setting the prefix correctly.



============================================================ Nathan Potter Oregon State University, COAS ndp at coas.oregonstate.edu 104 Ocean. Admin. Bldg. 541 737 2293 voice Corvallis, OR 97331-5503 541 737 2064 fax

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.