Chris Bedford
Usenet Archive
- Joined
- Mar 18, 2002
- Messages
- 18
- Reaction score
- 0
Hi:
this question has been driving me crazy. would be grateful for any help.
I am writing a version of the identity transformation to filter some documents (they happen to be wsdl docs). My problem is that for just about every element in the output document all of the namespace defintions defined in my top level element are emitted.
This makes for a very cluttered document. I'm wondering how i can surpress of the emission of these xmlns attributes from the output tree.
here is a simple example:
INPUT XML DOC:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:uang-bpws="http://www.siebel.com/uangrammar/2002/03/bpel4ws/" name="tfXWidgetSrc_WSDL" targetNamespace="http://www.o.com/">
<wsdl:import pig="dog"/>
<book xmlns:blah="urn:foo"/>
</wsdl:definitions>
XSLT DOC:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > <xsl:template match="node"> <xsl:copy> <xsl:apply-templates select="@*|node"/> </xsl:copy> </xsl:template>
<xsl:template match="@*[ not ( starts-with(name,'xmlns:') ) ]"> <xsl:copy-of select="."/> </xsl:template>
<xsl:template match="wsdl:definitions">
<wsdl:BLAH>
<xsl:apply-templates select="@*|node"/>
</wsdl:BLAH>
</xsl:template>
</xsl:stylesheet
RESULT:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:BLAH xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="tfXWidgetSrc_WSDL" targetNamespace="http://www.o.com/">
<wsdl:import xmlns:uang-bpws="http://www.siebel.com/uangrammar/2002/03/bpel4ws/" pig="dog"/> <book xmlns:uang-bpws="http://www.siebel.com/uangrammar/2002/03/bpel4ws/" xmlns:blah="urn:foo"/> </wsdl:BLAH>
Observations:
the output tree includes xmlns: attributes in both the wsdl:import tag and the book tag.... even though they were not defined in the input doc to begin with.
I tried to surpress the xmlns: attributes with
@*[ not ( starts-with(name,'xmlns:') ) ]
but that works the same as vanilla
@*
any advice much appreciated.
-chris
this question has been driving me crazy. would be grateful for any help.
I am writing a version of the identity transformation to filter some documents (they happen to be wsdl docs). My problem is that for just about every element in the output document all of the namespace defintions defined in my top level element are emitted.
This makes for a very cluttered document. I'm wondering how i can surpress of the emission of these xmlns attributes from the output tree.
here is a simple example:
INPUT XML DOC:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:uang-bpws="http://www.siebel.com/uangrammar/2002/03/bpel4ws/" name="tfXWidgetSrc_WSDL" targetNamespace="http://www.o.com/">
<wsdl:import pig="dog"/>
<book xmlns:blah="urn:foo"/>
</wsdl:definitions>
XSLT DOC:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" > <xsl:template match="node"> <xsl:copy> <xsl:apply-templates select="@*|node"/> </xsl:copy> </xsl:template>
<xsl:template match="@*[ not ( starts-with(name,'xmlns:') ) ]"> <xsl:copy-of select="."/> </xsl:template>
<xsl:template match="wsdl:definitions">
<wsdl:BLAH>
<xsl:apply-templates select="@*|node"/>
</wsdl:BLAH>
</xsl:template>
</xsl:stylesheet
RESULT:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:BLAH xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="tfXWidgetSrc_WSDL" targetNamespace="http://www.o.com/">
<wsdl:import xmlns:uang-bpws="http://www.siebel.com/uangrammar/2002/03/bpel4ws/" pig="dog"/> <book xmlns:uang-bpws="http://www.siebel.com/uangrammar/2002/03/bpel4ws/" xmlns:blah="urn:foo"/> </wsdl:BLAH>
Observations:
the output tree includes xmlns: attributes in both the wsdl:import tag and the book tag.... even though they were not defined in the input doc to begin with.
I tried to surpress the xmlns: attributes with
@*[ not ( starts-with(name,'xmlns:') ) ]
but that works the same as vanilla
@*
any advice much appreciated.
-chris