on 07-08-2008 8:13 AM
HI,
I need to remove/change specific xml tags from my output.
My input file is:
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ns1:Header>
<ns2:Security xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" mustUnderstand="1">
<ns2:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" Id="UsernameToken-27826089">
<ns2:Username>test</ns2:Username>
<ns2:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">test</ns2:Password>
</ns2:UsernameToken>
</ns2:Security>
</ns1:Header>
<ns1:Body>
<ns3:ExecuteChangesRequest xmlns:ns3="http://www.test.com/ns/fnce/2005/02/ws/schema">
<ns3:ChangeRequest id="1">
<ns3:TargetSpecification classId="Document" objectId="{BE26ED08-0142-4FD6-9EEF-04A58C018EC5}" objectStore="RegulatoryDevelopment" />
<ns3:Action xmlns:ns4="http://www.w3.org/2001/XMLSchema-instance" ns4:type="CheckoutAction" reservationType="Exclusive" />
<ns3:RefreshFilter maxRecursion="1">
<ns3:IncludeProperties>Reservation</ns3:IncludeProperties>
<ns3:IncludeTypes />
<ns3:ExcludeProperties />
</ns3:RefreshFilter>
</ns3:ChangeRequest>
</ns3:ExecuteChangesRequest>
</ns1:Body>
</ns1:Envelope>
I need to remove the ns3: from the all Body elements (ExecuteChangesRequest, ChangeRequest, TargetSpecification and Action) and also from the line "mlns:ns3="http://www.test.com/ns/fnce/2005/02/ws/schema">"
My output must look like this:
<soap:Body>
<ExecuteChangesRequest xmlns="http://www.test.com/ns/fnce/2005/02/ws/schema">
<ChangeRequest id="1">
<TargetSpecification classId="Document" objectId="{BE26ED08-0142-4FD6-9EEF-04A58C018EC5}" objectStore="RegulatoryDevelopment" />
<Action xsi:type="CheckoutAction" reservationType="Exclusive" />
<RefreshFilter maxRecursion="1">
<IncludeProperties>Reservation</IncludeProperties>
<IncludeTypes />
<ExcludeProperties />
</RefreshFilter>
</ChangeRequest>
</ExecuteChangesRequest>
</soap:Body>
Whi can help me with this ??
All help appreciated...
cheers
Fixed. I created a XSLT map using XSLT Mapper.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
If you use the following XSLT code, it will remove all the namespace and namespace prefix, then in a subsequent XSL try to pass the required namespace and attributes.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()" />
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:template match="text() | processing-instruction() | comment()">
<xsl:copy />
</xsl:template>
</xsl:stylesheet>
BR
Sameer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eric,
For Knowledge on XSLT transformation please have a look at the Basic tutorial
[http://www.w3schools.com/xsl]
the exclude-namespace Prefix is used to exculde the use of namespace Prefixes and namespaces from the Source XML File.
In your case you have NS3 as your prefix and the corresposning namespace as
xmlns:ns3="http://www.test.com/ns/fnce/2005/02/ws/schema
Typically XSLT values are Filled by means of XPATH expresions.
In your case the XPATH expression for your attributes would be as I specified in my previous post.
While you write the XPATH expression you may have to still use your Prefix NS3: ,
Hope this Clarifies.
Reward Points if this helps.
Regards,
Abhishek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eric,
This can be Simply done by Writing an XSL transform
Using the exclude-namespace Prefix ="ns3" xlmns:ns3=http://www.test.com/ns/fnce/2005/02/ws/schema
in the <xls:StyleSheet > element.
You Should only note that value getting the values for the attributes of the element , the XPATH should be like for example.
/ns3:ExecuteChangesRequest/ns3:ChangeRequest in the <xls:attribute> element of the XSLT.
<xsl:attribute name="ID">
<xsl:value-of select="/ns3:ExecuteChangesRequest/ns3:ChangeRequest/ID" />
</xsl:attribute
Hope this helps,
Reward points if useful
Regards,
Abhishek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply Abhishek,
I never done XSLT. Any change you can elaborate a bit more on the use of "exclude-namespace Prefix" ?
I also don't completely understand what you mean with:
"You Should only note that value getting the values for the attributes of the element , the XPATH should be like for example.
/ns3:ExecuteChangesRequest/ns3:ChangeRequest in the <xls:attribute> element of the XSLT."
cheers,
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.