RE: [xsl] How to generate an xmlns attribute with a prefix

Subject: RE: [xsl] How to generate an xmlns attribute with a prefix
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 6 Aug 2009 19:39:33 +0100
The important thing to remember is that if you get the element and attribute
names right, the namespace declarations will look after themselves (or
rather, the XSLT processor will look after them).

So to generate an xsi:schemaLocation attribute you do this:

<xsl:attribute name="xsi:schemaLocation"

and the xmlns:xsi declaration will appear automatically.


Michael Kay 


> -----Original Message-----
> From: Marc Van Limberghen [mailto:marc2jogger@xxxxxxxxx] 
> Sent: 06 August 2009 19:31
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] How to generate an xmlns attribute with a prefix
> Hello,
> I am transforming with XSL a source XML to a target XML. I 
> can design the source XML myself. I can not decide on the 
> structure of the target XML.
> The target XML must have as its root element the following 
> piece of XML:
> <beans xmlns=""; 
> xmlns:xsi=""; 
> xsi:schemaLocation="
> s 
> sd" default-lazy-init="true">
> I could obtain the xmlns attribute in my target XML, by 
> putting it in the <xsl:stylesheet> element.
> But I do not find a way to generate either the xmlns:xsi and 
> xsi:schemaLocation attributes.
> I read a lot of FAQs on namespaces and prefixes but could not 
> find an answer.
> I use:
> XML version 1.0
> XSLT Stylesheet version 1.0
> Xalan XSLT processor Xalan-Java v 2.7.1 (but I donot use 
> Java, I use XSL)
> All help is much appreciated!
> Marc

Current Thread