470,848 Members | 1,450 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

XSLT for an xml with namespace

HI

can anyone help me out with this, im a newbie to xml n stuff. i really
have tough time working on this .

Xml file:

<p:win32_Service xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://schemas.microsoft.com/wsman/2005/06/wmi/root/cimv2/win32_Service">
<p:AcceptPause>true</p:AcceptPause>
<p:AcceptStop>true</p:AcceptStop>
<p:Caption>Windows Management Instrumentation</p:Caption>
<p:StartMode>Auto</p:StartMode>
<p:StartName>LocalSystem</p:StartName>
<p:State>Running</p:State>
<p:Status>OK</p:Status>
<cim:Location xmlns:cim="http://schemas.dmtf.org/wsman/2005/06/base"
xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing"
"http://schemas.xmlsoap.org/ws/2005/06/management">
<a:Addres>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Addres>
<a:ReferenceParameters>
<w:ResourceURI>http://schemas.microsoft.com/wsman/2005/06/wmi/root/cimv2/win32_Service</w:ResourceURI>
<w:SelectorSet>
<w:Selector>Winmgmt</w:Selector>
</w:SelectorSet>
</a:ReferenceParameters>
</cim:Location>
</p:win32_Service>
From the above Xml i want to retieve only the Status,Caption and

StartName elements.

So i wrote an xsl code, which goes something like this

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cim="http://schemas.dmtf.org/wsman/2005/06/base"

xmlns:p="http://schemas.microsoft.com/wsman/2005/06/wmi/root/cimv2/win32_Service">

<xsl:output method="text"/>

<xsl:template match="/">
<xsl:apply-templates select="//p:Status|//p:Caption"/>
</xsl:template>

<xsl:template match="cim:Location"/>
<xsl:template match="p:Status">
<xsl:value-of select="p:Status" />
</xsl:template>
<xsl:template match="p:Caption">
<xsl:value-of select="p:Caption" />
</xsl:template>
</xsl:stylesheet>
When i run these two files in vbscript code, i cannot see any output??
i am trying to figure it out since a long time.

I appreciate if anyone can help me with this.
Regards

Apr 6 '06 #1
1 1219


sh*******@gmail.com wrote:

<xsl:template match="p:Status">
<xsl:value-of select="p:Status" />
Make that
<xsl:value-of select="." />
<xsl:template match="p:Caption">
<xsl:value-of select="p:Caption" />


Same here
<xsl:value-of select="." />

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Apr 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Mikko Nummelin | last post: by
1 post views Thread by Wil | last post: by
1 post views Thread by Sonu Kapoor | last post: by
4 posts views Thread by David S. Alexander | last post: by
1 post views Thread by Nick | last post: by
6 posts views Thread by kluge.wolfram | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.