[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: Dan Vint <dvint@xxxxxxxxx>
Date: Tue, 19 Apr 2005 20:35:51 -0700
copy of namespace node
I tired putting this exact statement with the node-set approach in a for-each loop to process the multiple declarations I have. At least from saxon I get a message saying I'm adding the same namespace. I set it up to create an element with a different name and also use the namespace that is read from my source file - so I know those are unique.

I thought I was getting a conflict with the couple of namespaces I can define on the stylesheet element, but that isn't the problem. I seem to be able to create one element and namespace with this technique - I use it for the target namespace declaration, but I can't get it to work with the additional imported namespaces and the for-each statement.

..dan

At 08:21 PM 4/19/2005, omprakash.v@xxxxxxxxxxxxx wrote:


Hi,
Just to add to David's comments:

You can create an element in a namespace using the following construct.

<xsl:element name="$elementname" namespace="{$nsname}">
</xsl:element>


Regards, Omprakash.V







David

Carlisle To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
<davidc@xxxxx cc: (bcc: omprakash.v/Polaris)
o.uk> Subject: Re: Trying to build a schema and add a namespace



04/20/2005


05:47 AM

Please

respond to

xsl-list










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 ________________________________________________________________________






This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only.
If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.


Visit Us at http://www.polaris.co.in

--------------------------------------------------------------------------- Danny Vint

Specializing in Panoramic Images of California and the West
http://www.dvint.com

voice: 510-522-4703

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.