473,320 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1300


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Mikko Nummelin | last post by:
As the XSLT namespace is declared to be used in XSL documents like this: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> , isn't this a risky practice as it...
1
by: Harry Zoroc | last post by:
I would like to treat an xsd Schema file as XML file and to display the targetNamespace and all the imports. That's it. But the following does not work. Why? I did not enter the stylesheet in the...
4
by: cyclops | last post by:
I'm trying to do XML + XSLT -> Another XML. The source XML contains multiple namespaces and XSLT will handle all possible tags under each name space. ----source---- <document xmlns="..."...
1
by: Wil | last post by:
I'm very new to developing in .NET and even newer to XML. The past few days have been pretty frustrating for me because I'm trying to perform a transform on data in a dataset and it's not working....
1
by: Sonu Kapoor | last post by:
Hi, I would like to use xpath with xslt. I know that this should be possible, but I dont get it ! Here is what I have tried so far: ==================================== my xml file:...
4
by: David S. Alexander | last post by:
How can I do simple subtraction in an XSLT. I want to read a few attribute values from an XML document, calculate their difference, and transform that value to an attribute in the XML output...
1
by: Nick | last post by:
I am working on a website for a client and one of their requirements was to have a mailing list. I decided to XSLT to transform "templates" to HTML so that editing was very easy and less time...
1
by: Rajesh | last post by:
I am trying to pass the namespace, which is in my Original Message, to a Java method for further processing. In the original message the xmlns:xenc namespace is present. I make a call to Java...
6
by: kluge.wolfram | last post by:
Hi, i get stucked on a transformation problem using XSLT. What i need is to copy an XML Tree to an output XML without any automatic changes. Since i used <xsl:copyor <xsl:copy-ofthere occur...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.