xslt - Remove namespace in xsl -
here xml:
<?xml version="1.0" encoding="utf-8" ?> <requestvaluesresponse xmlns="http://www.camstar.com/webservice/wsshopfloor"> <requestvaluesresult>true</requestvaluesresult> <responseservicedata q3:type="lotmodifyattrs" xmlns:q3="http://www.camstar.com/webservice/datatypes"> <completionmsg xmlns="http://www.camstar.com/webservice/datatypes">update completed successfully</completionmsg> <selectioncontainer xmlns="http://www.camstar.com/webservice/datatypes"> <__name>5454545</__name> <__level> <__name>lot</__name> </__level> <__id>4802378000000610</__id> </selectioncontainer> <serviceattrsdetailsselection xmlns="http://www.camstar.com/webservice/datatypes"> <__listitem type="serviceattrsdetails"> <__parent> <__id>4806490000000018</__id> </__parent> <__id>4805ad00000001c5</__id> <attributename>allowlotschedule</attributename> <attributevalue>true</attributevalue> </__listitem> <__listitem type="serviceattrsdetails"> <__parent> <__id>4806490000000018</__id> </__parent> <__id>4805ad00000001c9</__id> <attributename>assemblycountry</attributename> <attributevalue/> </__listitem> </serviceattrsdetailsselection> </responseservicedata> <resultstatus type="q1:resultstatus" xmlns:q1="http://www.camstar.com/webservice/datatypes"> <message xmlns="http://www.camstar.com/webservice/datatypes">update completed successfully</message> <iserror xmlns="http://www.camstar.com/webservice/datatypes">false</iserror> </resultstatus> </requestvaluesresponse>
here how xsl looks like:
<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns2="http://www.camstar.com/webservice/wsshopfloor" xmlns:q3="http://www.camstar.com/webservice/datatypes" exclude-result-prefixes="q3 xsi xsl xsd wsdl ns2"> <xsl:output omit-xml-declaration="yes"/> <xsl:template match="/"> <attributedetailscollection> <xsl:copy-of select="/ns2:requestvaluesresponse/ns2:responseservicedata/q3:serviceattrsdetailsselection"> <?oracle-xsl-mapper-position serviceattrsdetailsselection?> </xsl:copy-of> </attributedetailscollection> </xsl:template> </xsl:stylesheet>
and output xsl:
<?xml version = '1.0' encoding = 'utf-8'?> <attributedetailscollection> <serviceattrsdetailsselection xmlns="http://www.camstar.com/webservice/datatypes" xmlns:q3="http://www.camstar.com/webservice/datatypes"> <__listitem type="serviceattrsdetails"> <__parent> <__id>4806490000000018</__id> </__parent> <__id>4805ad00000001c5</__id> <attributename>allowlotschedule</attributename> <attributevalue>true</attributevalue> </__listitem> <__listitem type="serviceattrsdetails"> <__parent> <__id>4806490000000018</__id> </__parent> <__id>4805ad00000001c9</__id> <attributename>assemblycountry</attributename> <attributevalue/> </__listitem> </serviceattrsdetailsselection> </attributedetailscollection>
notice line in output:
<serviceattrsdetailsselection xmlns="http://www.camstar.com/webservice/datatypes" xmlns:q3="http://www.camstar.com/webservice/datatypes">
preferably want both namespace declaration removed, should be:
<serviceattrsdetailsselection>
but @ minimum should like:
<serviceattrsdetailsselection xmlns:q3="http://www.camstar.com/webservice/datatypes">
i can deal namespace prefix.
you can't use copy-of
if want change namespace. push elements through templates strip namespace:
<xsl:template match="/"> <attributedetailscollection> <xsl:apply-templates select="/ns2:requestvaluesresponse/ns2:responseservicedata/q3:serviceattrsdetailsselection"> </attributedetailscollection> </xsl:template> <xsl:template match="ns2:*"> <xsl:element name="{local-name()}"> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:element> </xsl:template>
Comments
Post a Comment