newbie xslt help
Posted: Fri Jun 06, 2008 12:14 pm
Hallo Forum,
I got a xml-based file to convert into a different form and to filter. No problem using xslt - but - because I'm pretty new to xslt I can't get it to work.
Example-xml:
The resultant xml-file should include
1. all <line/> with 2 or more <pt/> (works with <xsl:if test="count(nd)>=2">) AND
2. all <point/> referenced by <pt ref="#"> including rule 1. => this is where my problems start.
The result should look like this (the original file to process is about 1GB!):
=> <line id="2"> removed, too less <pt/>
=> <point id="4 and 6"> removed, not referenced (anymore)
Any hints?
I got a xml-based file to convert into a different form and to filter. No problem using xslt - but - because I'm pretty new to xslt I can't get it to work.
Example-xml:
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<test>
<point id="1" a="11" b="111">
<tag k="name" v="a"/>
<tag k="name2" v="a2"/>
</point>
<point id="2" a="22" b="222">
<tag k="name" v="b"/>
<tag k="adr" v="fun"/>
</point>
<point id="3" a="33" b="333"/>
<point id="4" a="44" b="444"/>
<point id="5" a="55" b="555"/>
<point id="6" a="66" b="666"/>
<line id="1" A="1111" B="11111">
<pt ref="1"/>
<pt ref="2"/>
<pt ref="3"/>
<tag k="rest" v="5"/>
<tag k="abx" v="finish"/>
</line>
<line id="2" A="2222" B="22222">
<nd ref="5"/>
<tag k="hun" v="trips"/>
</line>
<line id="3" A="333" B="33333">
<nd ref="2"/>
<nd ref="5"/>
<tag k="all" v="56"/>
</line>
</test>
1. all <line/> with 2 or more <pt/> (works with <xsl:if test="count(nd)>=2">) AND
2. all <point/> referenced by <pt ref="#"> including rule 1. => this is where my problems start.
The result should look like this (the original file to process is about 1GB!):
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<test>
<point id="1" a="11" b="111">
<tag k="name" v="a"/>
<tag k="name2" v="a2"/>
</point>
<point id="2" a="22" b="222">
<tag k="name" v="b"/>
<tag k="adr" v="fun"/>
</point>
<point id="3" a="33" b="333"/>
<point id="5" a="55" b="555"/>
<line id="1" A="1111" B="11111">
<pt ref="1"/>
<pt ref="2"/>
<pt ref="3"/>
<tag k="rest" v="5"/>
<tag k="abx" v="finish"/>
</line>
<line id="3" A="333" B="33333">
<nd ref="2"/>
<nd ref="5"/>
<tag k="all" v="56"/>
</line>
</test>
=> <point id="4 and 6"> removed, not referenced (anymore)
Any hints?