cancel
Showing results for 
Search instead for 
Did you mean: 

XLST mapping removing or renaming specific XML tags

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Fixed. I created a XSLT map using XSLT Mapper.

Former Member
0 Kudos

Eric, I saw that you posted some raw SOAP/XML for the CheckoutAction for the FileNet Web Service. Anyway, would you happen to have a CreateAction SOAP/XML string that I can look at. I am having an issue with the format I believe and would like to see the raw text for this XML. Thanks, Garet

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi, thanks for that, but that's a bit too much. It strips all the namespace prefixes..and I only need to get rid of the one ns3 one...

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi, thanks for that.

Its not what I'm after. The exclude-namespace Prefix removes the whole element. I only need to rename the element from <ns3:element> to <element>

cheers,

eric

Former Member
0 Kudos

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

Former Member
0 Kudos

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,