XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Doug LundinSubject: Help to tune up this XSLT
Author: Doug Lundin
Date: 18 Apr 2009 12:10 PM
Hi,

I've got an XML dataset like this:
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<ns3:getMocksByFilterResponse xmlns="java:mocksvc.value" xmlns:ns3="mocksvc">
<ns3:arrayOfMock_result>
<Mock xsi:type="Corridor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<name>Name1</name>
</Mock>
<Mock xsi:type="Corridor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<name>Name2</name>
</Mock>
<Mock xsi:type="Circle" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<name>Name3</name>
</Mock>
</ns3:arrayOfMock_result>
</ns3:getMocksByFilterResponse>
</env:Body>
</env:Envelope>


And am using this XSLT:
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="java:mocksvc.value">
<xsl:output method="xml" indent="no"/>
<xsl:template match="a:Mock">
<xsl:element name="Name">
<xsl:value-of select="a:name" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>


Which is returning:
<?xml version='1.0' ?>





<Name xmlns:a="java:mocksvc.value">Name1</Name>
<Name>Name2</Name>
<Name>Name3</Name>


What I really want to see is this:
<?xml version='1.0' ?>
<Highest>
<Name>Name1</Name>
<Name>Name2</Name>
<Name>Name3</Name>
</Highest>

This should be easy to do but I haven't been able to figure it out. Anyone have a solution?

Thanks!
Doug

Posttop
John BamptonSubject: Help to tune up this XSLT
Author: John Bampton
Date: 19 Apr 2009 11:29 AM
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="java:mocksvc.value" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:output method="xml" indent="no"/>
<xsl:template match="/">
<Highest>
<xsl:apply-templates select="/env:Envelope/env:Body/*[namespace-uri()='mocksvc' and local-name()='getMocksByFilterResponse']/*[namespace-uri()='mocksvc' and local-name()='arrayOfMock_result']/*[namespace-uri()='java:mocksvc.value' and local-name()='Mock']"></xsl:apply-templates>
</Highest>
</xsl:template>

<xsl:template match="a:Mock">
<xsl:element name="Name">
<xsl:value-of select="a:name" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Cheers, John Bampton.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.