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

Re: Trying to build a schema and add a namespace

Subject: Re: Trying to build a schema and add a namespace
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 20 Apr 2005 01:17:27 +0100
xsl add schema
Generating namespace nodes is a faq, I'm sure DaveP's faq pages will
have essentially the following, but...

If you are using xslt2 draft you can use the new <xsl:namespace
instruction added for just this reason.

If you are using the current XSLT1 rec then there are essentially two
ways to get a namespace node in to the result:

copy it from the source or generate an element or attribute in that
namespace and let the xslt system infer the namespace node.

You don't say what your input looks like

> My source file has a list of the target namespace and the files to
> import 

If the namespace information is actually stored in the input file as
namespaces then you are in good shape, you can just copy the namespace
nodes from the source tree using the namespace axis.

If you don't store the information as namespaces but just store the
namespace URI in element or attribute content then you have two choices:

suppose your source has
 <pfx>accord-doc</pfx>
 <ns>ACORD doc URL</ns>
and you want to generate
           xmlns:acord-doc="ACORD doc URL"

Then you can either go
<xsl:attribute name="{pfx}:foo" namespace="{ns}"/>
which will put 
accord-doc:foo=""  xmlns:acord-doc="ACORD doc URL"
into the result and you either live with the paccord-doc:foo attribute
or kill it with a post-process, or if you have a xx:node-set() extension
function you can do
<xsl:variable name="x">
<x>
<xsl:attribute name="{pfx}:foo" namespace="{ns}"/>
</x>
</xsl:variable>
<xsl:copy-of select="xx:node-set($x)/x/namespace::*[.=current()/ns]"/>
which will just copy the namespace node to the result tree.

David



you shouldn't ever need
           xmlns:xml="W3C url for XML namespace - need for xml:lang use"

should you XSLT won't generate this one, result trees always have this
namespace node but the serialisation never puts in the namespace
declaration, as it's always implictly declared anyway.


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.