xsl-list
[Top] [All Lists]

Re: Trying to build a schema and add a namespace

2005-04-19 20:21:34


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(_at_)lists(_dot_)mulberrytech(_dot_)com                                
   
                    <davidc(_at_)nag(_dot_)c        cc:     (bcc: 
omprakash.v/Polaris)                                        
                    o.uk>                Subject:     Re: [xsl] 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
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--






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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--