newbie xslt help

Here should go questions about transforming XML with XSLT and FOP.
crash_override
Posts: 1
Joined: Fri Jun 06, 2008 12:07 pm

newbie xslt help

Post by crash_override »

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:

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>
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!):

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>
=> <line id="2"> removed, too less <pt/>
=> <point id="4 and 6"> removed, not referenced (anymore)

Any hints?
jkmyoung
Posts: 89
Joined: Mon Mar 06, 2006 10:13 pm

Re: newbie xslt help

Post by jkmyoung »

Post your XSLT, and it'll be easier to see where you're going wrong.
Post Reply