Created
June 11, 2011 05:01
-
-
Save emiliano-poggi/1020269 to your computer and use it in GitHub Desktop.
XSLT: Bypassing elements of a given namespace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:ns1="http://s1"> | |
<xsl:output omit-xml-declaration="yes" indent="yes"/> | |
<xsl:strip-space elements="*"/> | |
<xsl:template match="node()|@*"> | |
<xsl:copy> | |
<xsl:apply-templates select="node()|@*"/> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match= | |
"*[not(attribute::ns1:*) | |
and | |
not(descendant-or-self::ns1:*) | |
] | |
| | |
@*[not(namespace-uri()='http://s1')] | |
"/> | |
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Collection xmlns="http://s0" xmlns:ns1="http://s1"> | |
<Identifier Name="CollectionX" | |
ns1:GlobalID="{E436833B-B0A6-4E0D-804B-60052B767AE3}" | |
ns1:LocalID="{0130C866-7A91-4544-A82B-E0C0F2E3BCB2}" /> | |
<Properties> | |
<ns1:Collectible>1982</ns1:Collectible> | |
<Displayed>Reserved</Displayed> | |
<Picture>Reserved.jpeg</Picture> | |
</Properties> | |
<WeakLinks> | |
<Link Type="resource" Language="en-us"/> | |
</WeakLinks> | |
</Collection> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Collection xmlns="http://s0" xmlns:ns1="http://s1"> | |
<Identifier | |
ns1:GlobalID="{E436833B-B0A6-4E0D-804B-60052B767AE3}" | |
ns1:LocalID="{0130C866-7A91-4544-A82B-E0C0F2E3BCB2}" /> | |
<Properties> | |
<ns1:Collectible>1982</ns1:Collectible> | |
</Properties> | |
</Collection> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This transform overrides the identity rule to filter all elements/attributes which do not belong to the target namespace and are not parent of elements/attributes with the target namespace.
Credits.