You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Brett McLaughlin <br...@earthlink.net> on 2000/04/09 02:56:44 UTC

Namespace insertion in resultant DOM tree

I notice that for this stylesheet:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"                 
               
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                
                xmlns:JavaXML="http://www.oreilly.com/catalog/javaxml"
>

  <!-- transformation -->

</xsl:stylesheet>

that whaterver output I have, the resulting root element has added to it
namespace declarations for all but the XSL Transformation namespace. 
For example:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"                 
               
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                
                xmlns:JavaXML="http://www.oreilly.com/catalog/javaxml"
>

 <xsl:template match="JavaXML:Book">
  <wml>
   <card id="index">
    <p align="center">Hello World!</p>
   </card>
  </wml>
 </xsl:template> 

</xsl:stylesheet>

The output I dictated was (assuming I had a JavaXML:Book element):

<wml>
 <card id="index">
  <p align="center">Hello World!</p>
 </card>
</wml>

However, what I get is:

<wml xmlns:JavaXML="http://www.oreilly.com/catalog/javaxml">
 <card id="index">
  <p align="center">Hello World!</p>
 </card>
</wml>

This is bad, because it breaks the WML interpreter, which doesn't know
what to do with the xmlns:JavaXML attribute.  But I must declare it in
my stylesheet, because I am reading from an incoming DOM tree with
namespaces in use.  Is there any way to specify either to XSL or to
Xalan that a namespace is orthogonal, and should be used in input but
not appended as an attribute to the resultant DOM tree?

I really need this functionality, and frankly think lots of people doing
WML will once they start using namespaces.  Thanks for help!

-brett

Re: Namespace insertion in resultant DOM tree

Posted by Steve Muench <sm...@us.oracle.com>.
| However, what I get is:
| 
| <wml xmlns:JavaXML="http://www.oreilly.com/catalog/javaxml">
|  <card id="index">
|   <p align="center">Hello World!</p>
|  </card>
| </wml>
| 

Bret,

try adding the following attribute to your <xsl:stylesheet>
element:

   exclude-result-prefixes="JavaXML"

So if your source is:

<Book xmlns:JavaXML="http://www.oreilly.com/catalog/javaxml"/>

and your stylesheet is:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                xmlns:JavaXML="http://www.oreilly.com/catalog/javaxml"
                exclude-result-prefixes="JavaXML">

  <xsl:output indent="yes"/>

  <xsl:template match="/">
    <wml>
     <card id="index">
      <p align="center">Hello World!</p>
     </card>
    </wml>
  </xsl:template>

</xsl:stylesheet>

then your output should be (I checked with Oracle XSLT, XT, Saxon
and the MSXSL latest tech preview) but I'm sure Xalan does the same
thing.

______________________________________________________________
Steve Muench, Lead XML Evangelist & Consulting Product Manager
Business Components for Java Dev't Team, Oracle Corporation