Skip to content

Commit

Permalink
selecting only given elements from xml
Browse files Browse the repository at this point in the history
  • Loading branch information
mizarcvs committed Apr 10, 2007
1 parent 58ab5e1 commit 4b76ee7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions selectelems.xsltxt
@@ -0,0 +1,29 @@
stylesheet 1.0;

// XSLTXT (https://xsltxt.dev.java.net/) stylesheet
// selecting only given elements from the xml

// To produce standard XSLT from this do e.g.:
// java -jar xsltxt.jar toXSL selectelems.xsltxt > selectelems.xsl

// Then e.g.: xsltproc selectelems.xsl ordinal2.xml > ordinal2.xml1


output method=xml;

#selected = { "Pattern"; }

tpl [*](#in)
{
if [(name() = $selected) or ($in = 1)]
{
copy { apply [@*](#in="1"); apply(#in="1"); }
if [(name() = $selected)] { "

"; }
}
else { apply(#in=$in); }
}

tpl [@*](#in) { if [$in = 1 ] {copy-of `.`; }}
tpl [text()](#in) { if [$in = 1 ] {copy-of `.`; }}

0 comments on commit 4b76ee7

Please sign in to comment.