473,513 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get the identity transformation to stop outputting extra 'xmlns:' attrib ? _clb_

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
Jul 20 '05 #1
1 4120
sp*****@perigon.com (Chris Bedford) writes:
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.
<snip/>
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.

This seems to be processor dependent. With Sablotron I get the same
result as you, whereas xsltproc gives the result

<wsdl:BLAH xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="tfXWidgetSrc_WSDL" targetNamespace="http://www.o.com/">

<wsdl:import pig="dog"/>
<book xmlns:blah="urn:foo"/>
</wsdl:BLAH>

I am no namespace expert, but the latter would seem to be more
sensible. Which is *correct* I have no idea.

If you want to copy all of the input nodes into your output namespace
then you must avoid using <xsl:copy/> and <xsl:copy-of/> and make new
versions of all elements to be copied. This pair of templates applies
the identity-without-namespaces transformation:

<xsl:template match="node()">
<xsl:element name="{name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>

<xsl:template match="@*|text()|comment()|processing-instruction()">
<xsl:copy/>
</xsl:template>
Ben

--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7897
by: pradeep gummi | last post by:
I have an XML FILE that is to be converted to Plain Text using an XSL file. Since I just want plain text, I do not want to set any root element during transformation.And if I do not any root element during transformation, it return s "java.lang.IllegalStateException: Root element not set" exception. If I add any element for the enclosed...
4
2420
by: Kevin Dean | last post by:
I'm trying to create an XSL transformation that will strip out development-specific attributes from deployment descriptors and other XML files. I have already successfully done so with web.xml but I'm at a complete loss as to what is wrong with the one below. This is a very abbreviated server-config.wsdd: <?xml version="1.0"...
2
2688
by: Wolfgang | last post by:
I'm applying a simple XSLT style sheet to an XML file. The style sheet is: http://piru.alexandria.ucsb.edu/~rnott/MetadataMapping/access-report.xsl The XML file is here: http://piru.alexandria.ucsb.edu/~rnott/MetadataMapping/dlese-adn.xml This works fine as long as the root element of the XML file is plain
8
2568
by: David Dorward | last post by:
I'm looking for an XSLT that I can use to transform XHTML 1.0 Strict into HTML 4.01. Does anyone know of a nice prewritten one? -- David Dorward <http://dorward.me.uk/>
7
1483
by: Bilal | last post by:
Hello, I'm attempting to "populate" an template XML file with some data using identity transform (approach suggested by Joe K.; Thanks! :-) and have come across some strange behaviour using XMLSpy, AltovaXML, and xsltproc. The actual stylesheets are to be auto-generated by another stylesheet (that process I've worked out! :-) and now...
4
4292
by: =?Utf-8?B?REZC?= | last post by:
Within an XSLT transformation, I'm trying to switch the default namespace within a section of the generated XML document to a shared namespace. This way, the content of this section does not have to use a prefix for the shared namespace, thus making the document smaller and easier to read. This worked in .NET 1.1 with no problem, but now...
5
3897
by: mahesh.nimbalkar | last post by:
When I transform XML, XSLT automatically adds extra attributes to the node which are declared in DTD (default DTD attributes) . I just want XSLT not to add these extra default attributes from DTD. See refname and shortname attributes are added to node automatically after transformation. Please let me know how to fix this. ...
2
1996
by: sarah12 | last post by:
Hi, I want to change : <?xml version="1.0" ?> <nplbiblio > <document status="U" creadate="19990410"> <xp>000000001</xp> <doctype>JOURN-ART</doctype> <prdate>19880901</prdate>
1
2202
by: boetke | last post by:
Hi all, I am attempting to create an xslt transformation which I am having trouble with. I am fairly new to xslt and am having a hard time getting my head around it. The original xml file looks like this: <DataSet ID="-5480"> <ObsGroup> <ClsItem name="AGE">2099</ClsItem> <ClsItem name="COMB_DATA">20</ClsItem> <ClsItem...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.