xsl-list
[Top] [All Lists]

RE: [xsl] Need help with XSLT: adding new node btw existing elements

2006-08-16 15:56:19
Put the elements in the right namespace, and the namespace declarations will
take care of themselves. 

I suspect that you want to generate the environment and variable elements in
the blabla namespace, in which case you need to prefix their names in the
stylesheet.

Michael Kay
http://www.saxonica.com/
 

-----Original Message-----
From: Nishi Bhonsle [mailto:nishiandprafull(_at_)gmail(_dot_)com] 
Sent: 16 August 2006 23:47
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Need help with XSLT: adding new node btw 
existing elements

Okay, I could remove the blabla namespace from the output xml 
doc by adding exclude-result-prefixes="b" in my xslt doc.

But what about the xmlns="" that gets added to the elements? 
How can I remove that?

Thanks!

On 8/16/06, Nishi Bhonsle <nishiandprafull(_at_)gmail(_dot_)com> wrote:
David:
I tried this but in the output, i notice that the namespace 
gets added 
as attributes to the environment as well as variable elements. Is 
there way that can be avoided?

xslt -

<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:b="blabla"> 
<xsl:output method="xml" version="1.0" encoding="UTF-8" 
indent="yes"/> 
<xsl:template match="node() | @*"> <xsl:copy>  <xsl:apply-templates 
select="node() | @*" />  </xsl:copy>  </xsl:template>  
<xsl:template 
match="b:environment"> <environment>  <variable id="SAROOTDIR" 
value="D:\Dir1"/>  <variable id="SADATADIR" value="D:\Dir2"/>  
</environment>  </xsl:template> </xsl:stylesheet>

and the output looks like -

<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet 
type="text/xsl" href="C:\test1.xslt"?> <test xmlns="blabla"> <comp 
id="New"> <process-type id="home"> <environment xmlns="" 
xmlns:b="blabla"> <variable xmlns="" id="SAROOTDIR" 
value="D:\Dir1"/> 
<variable xmlns="" id="SADATADIR" value="D:\Dir2"/> </environment> 
</process-type> </comp> </test>

Thanks!


On 8/16/06, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:


<xsl:template match="environment">

that matches elements called environment in no namespace but you 
have no such elements, your original example looked like:

<test xmlns="blabla">
<comp id="New">
<process-type id="home" module-id="TESTER" status="enabled"> 
<environment>

so your document has an element environment in the 
namespace blabla 
to match an element of that name put xmlns:b="blabla" in your xsl 
stylesheet and use

<xsl:template match="b:environment">

(This is a FAQ)

David


--~-----------------------------------------------------------------
- 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>
--~--




--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>