[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] [XSLT 1.0] Strip unused namespaces, but retain namespa
Hi Folks, I want to transform this: -------------------------------------------- <t:Test xmlns:t="http://www.test.org" xmlns:unused="http://www.unused.org" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <t:faultcode>SOAP:client</t:faultcode> </t:Test> -------------------------------------------- to this: ------------------------------------ <Test xmlns="http://www.test.org" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <faultcode>SOAP:client</faultcode> </Test> ------------------------------------ That is, I want to: 1. Replace namespace-qualified elements with a default namespace, e.g., Change this: <t:Test xmlns:t="..." to this: <Test xmlns="..." 2. Delete unused namespace declarations, e.g., Delete this: xmlns:unused="..." 3. Retain a namespace declaration if it declares a namespace prefix that is used in an element QName value, e.g., Retain this: xmlns:soap="..." because the prefix is used in this element's value: <faultcode>SOAP:client</faultcode> The following template rule does (1) and (2) but fails to implement (3): <xsl:template match="*[namespace-uri()]"> <xsl:element name="{local-name()}" namespace="{namespace-uri()}"> <xsl:apply-templates select="@* | node()"/> </xsl:element> </xsl:template> Any ideas? I am using XSLT 1.0 /Roger
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|