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

Re: empty namespace declaration being generated

Subject: Re: empty namespace declaration being generated
From: David Bertoni <david.bertoni@xxxxxxxxx>
Date: Wed, 24 Jan 2007 00:12:36 -0800
Re:  empty namespace declaration being generated
Scott Smith wrote:
First, you're right about Xalan (1.1; the xerces c++ library is 2.7.0).

Xalan-C 1.10, not Xalan-C 1.1 -- there is a difference.


Second, I hear what you are saying. What I don't understand is why ALL of the tags that pulled data from the no-namespace xml file didn't also have the xmlns="". In the original xsl, I pull 20 some odd data tags from the original xml file and the only one that caused the xmlns="" was this one.


It's difficult to say why without seeing the full output. Remember that namespace bindings are hierarchical within an XML document, so any elements in the result tree that are descendants of an element where the default namespace is not defined will not need a namespace declaration that undefines it. For example:


  <?xml version="1.0" encoding="UTF-8"?>
  <stocks xmlns="http://www.fred.com/something">
    <security xmlns="" exchange="NASDAQ" ticker="BMET">
      <example-child-element/>
    </security>
    <security xmlns="" exchange="NYSE" ticker="JNJ"/>
 </stocks>

What I want is that all of the elements, attributes, etc. in the output xml file are under the www.fred.com/something namespace.

Then you need to make sure _all_ of the literal result elements in your stylesheet are in that namespace. The easiest way is to place the default namespace declaration in the xsl:stylesheet element:


  <xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.fred.com/something">

...

You probably _don't_ want the attributes in that namespace, but, if you do, you'll need to use a prefix that is bound to that namespace for the attributes, since the default namespace does not apply to attribute names.

Can someone point me to an FAQ or tutorial article that explains the affect of different placements of the namespace declaration?

You might want to read the XML Namespaces recommendation:


http://www.w3.org/TR/REC-xml-names/

It's also important that you understand how an XSLT processor generates the result tree. There are any number of XSLT books that can explain that, but Michael Kay's is probably the best.

Dave

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.