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
Karen FoxSubject: Grabbing sub-namespace values
Author: Karen Fox
Date: 04 Nov 2008 01:21 PM
I'm pulling schemas out of WSDLs but have one problem. Because I have to match on a variety of schema elements, I'm trying to be as generic as possible on matching the schema elements.

<xsl:template match="s:schema | a:schema | xsd:schema | schema">

How can I grab the namespace values associated with this schema element? I've tried many different ways but nothing works. I can't use copy/copy-of for this since it messes up other things I have to do.

Example WSDL: All I want are the wsdl and soapenc namespaces.

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="PriceListService"
targetNamespace="http://www.ecerami.com/wsdl/PriceListService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.ecerami.com/wsdl/PriceListService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsd1="http://www.ecerami.com/schema">

<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.ecerami.com/schema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">

<complexType name="ArrayOfString">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType"
wsdl:arrayType="string[]"/>
</restriction>
</complexContent>
</complexType>
<complexType name="ArrayOfDouble">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType"
wsdl:arrayType="double[]"/>
</restriction>
</complexContent>
</complexType>
</schema>
</types>

Thanks!

Karen Fox
kfox@mitre.org

Posttop
Alberto MassariSubject: Grabbing sub-namespace values
Author: Alberto Massari
Date: 06 Nov 2008 03:35 AM
Hi Karen,
the prefix used in the WSDL you are processing is not important, what you really need is the namespace that prefix is mapped to.
So, writing in your XSLT

<xsl:template match="xsd:schema">

(after having associated "xsd" to the XML Schema namespace in the xsl:stylesheet element) is enough to match either s:schema or a:schema.
As for what you are trying to extract: in XSLT 1.0 you can use the "namespace" axis to retrieve the namespace nodes that are in scope at a specified level, including the one defined there and the one inherited from the parent node. In XSLT 2.0 you can use the in-scope-prefixes() function.

Hope this helps,
Alberto

 
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.