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
Nadège GriesserSubject: Can't make template match element (namespace problem?)
Author: Nadège Griesser
Date: 23 Nov 2006 06:50 AM
Hello,

I would like to turn this xml file :
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Header>
<header xmlns="xmlapi_1.0">
<requestID>XmlApiClient:26</requestID>
</header>
</SOAP:Header>
<SOAP:Body>
<findResponse xmlns="xmlapi_1.0">
<result>
<netw.NetworkElement>
<ipAddress>138.120.202.223</ipAddress>
<name>10.1.1.223</name>
</netw.NetworkElement>
</result>
</findResponse>
</SOAP:Body>
</SOAP:Envelope>

into this one :
<IP_MPLS>
<NE ID="10.1.1.223">
<IP>138.120.202.223</IP>
</NE>
</IP_MPLS>

That is to say : remove SOAP namespace, remove findResponse tag, replace result tag with IP_MPLS, replace netw.NetworkElement tag with NE add an "ID" attribute with the value of the name tag, ...

The problem is that I am unable to match the findResponse tag.
I guess this is linked with namespaces...

Here is the stylesheet :
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="xmlapi_1.0" exclude-result-prefixes="SOAP" version="1.0">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
<xsl:apply-templates select="SOAP:Envelope/SOAP:Body/node()"/>
</xsl:template>

<xsl:template match="findResponse">
<xsl:apply-templates select="result"/>
</xsl:template>

<xsl:template match="result">
<IP_MPLS>
<xsl:apply-templates select="node()"/>
</IP_MPLS>
</xsl:template>

<xsl:template match="netw.NetworkElement">
<NE>
<xsl:attribute name="ID">
<xsl:value-of select="name" />
</xsl:attribute>
<xsl:apply-templates select="node()"/>
</NE>
</xsl:template>

<xsl:template match="*">
<xsl:copy />
</xsl:template>

</xsl:stylesheet>

The findResponse tag matches with "*" and not with findResponse.

Thanks in advance for your suggestions.

Nadège

Postnext
(Deleted User) Subject: Can't make template match element (namespace problem?)
Author: (Deleted User)
Date: 23 Nov 2006 07:27 AM
Hi Nadege,
just add a xmlns:q="xmlapi_1.0" to the xsl:stylesheet node and replace findResponse with q:findResponse (as well as 'result', 'name', etc..)

Hope this helps,
Alberto

Posttop
Nadège GriesserSubject: Can't make template match element (namespace problem?)
Author: Nadège Griesser
Date: 23 Nov 2006 07:53 AM
Hi Alberto,

Thanks for your help, it works perfectly.

Nadège

 
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.