Subject: Re: [xsl] Trying to build a schema and add a namespace From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 20 Apr 2005 01:17:27 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Trying to build a schema and , Dan Vint | Thread | Re: [xsl] Trying to build a schema , omprakash . v |
[xsl] Trying to build a schema and , Dan Vint | Date | Re: [xsl] Trying to build a schema , omprakash . v |
Month |