xsl-list
[Top] [All Lists]

Re: [xsl] Global namespace prefixes (Corrected Examples)

2008-11-14 01:15:02



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="{(_at_)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



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>