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

Re: I need to make sure that all namespace declaration

Subject: Re: I need to make sure that all namespace declarations get output to a particular element, not the document element
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Mar 2007 14:14:49 +0100
Re:  I need to make sure that all namespace declaration
At 2007-03-22 13:51 +0100, bryan rasmussen wrote:
I have a situation where the processor is obviously optimising
namespace creation and placing them all over the place, unfortunately
I need to place them exactly on a particular element.

I've not heard of a processor moving a required namespace declaration "up" the result tree. Once an element in the result tree is constructed, the adding of children nodes to the element wouldn't typically change the completed parent element.


The relevant steps of the transformation are:

But you are missing showing us the declaration at the top and the namespaces in the stylesheet document element ... are you declaring the "xmlns:in" namespace there?


<xsl:template match="/">
<office:document-content office:version="1.0"
...
<xsl:apply-templates select="ns:node-set($instancedocument)/*" mode="toplevel"/>
</xsl:template>


the template that handles toplevel matching does a lot of ordering of
the document and uses
<xsl:copy-of select="self::*"/>
to output the actual instance inside of an xforms:model element:

which looks like this when it comes out

<xforms:model id="Invoice" xmlns:n="nodesetvariables"
xmlns:in="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0">
<xforms:instance id="Instance_1">
<in:Invoice>

unfortunately I absolutely need to have xmlns:in to show up on the
in:Invoice element (as well as a couple other namespace declarations)
if I expect this to work with Open Office (rant about Open Office /
xforms omitted for sake of not making people go insane)

Your output indicates to me that an ancestor of the xforms:model element in your stylesheet has the invoice namespace. That is assuming the xforms:model comes from a literal result element in your stylesheet.


So how should I best accomplish this, should I exclude namespace at
the top of my stylesheet, thus forcing the processor to put it back in
elsewhere (doesn't actually seem to work because hey I need to control
exactly where my namespace gets put. nothing else will do. )

Sometimes I have used techniques such as:


<xsl:stylesheet xmlns:xforms="..." ...>

  <xsl:template ...>
    <xsl:call-template name="do-invoice"/>
  </xsl:template>

  <xsl:template name="do-invoice" match="in:Invoice" xmlns:in="....">
    <in:Invoice ...>
  </xsl:template>

... so as to focus the use of namespaces in my stylesheet.

Alternatively, one might use an imported or included stylesheet in which the UBL namespaces are declared, but not in the importing or including stylesheet.

I hope this helps.

. . . . . . . . . . . . Ken

--
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

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.