[xsl] Group and filter with XSL

Subject: [xsl] Group and filter with XSL
From: "contest.vix" <contest.vix@xxxxxxxxxx>
Date: Mon, 13 Dec 2004 15:29:27 -0200
Hi,
I'm trying to transform a XML document in another XML document. The
transformation is basicaly a copying the input XML but I have  to identify and
group an especific group of elements. Does somebody know if is possible to use
XSL for that and how?

An Example:
the input XML has a DTD similar to this:
---begin DTD
<!ELEMENT c (c*)>
<!ATTLIST c
	ext CDATA #REQUIRED
	form CDATA #IMPLIED
>
<!ELEMENT p (s*)>
<!ATTLIST p
	id ID #REQUIRED
>
<!ELEMENT s (c*)>
<!ATTLIST s
	id ID #REQUIRED
>
<!ELEMENT data (p+)>
---end DTD

So the problem is that I have to group all elements "c" with attributes
ext="tag" and form="n" that have one element "c" with attributes ext="tag" and
form="n" among them at the same level of the XML tree.

An Example of XML input:
----begin xml
<data>
	<p id="p_1">
		<s id="s_1">
			<c ext="root" form="fcl">
				<c ext="tag" form="n">
					<c ext="n" form="att"/>
					<c ext="h" form="n"/>
				</c>
				<c ext="tag" form="n">
					<c ext="n" form="att"/>
					<c ext="h" form="n"/>
				</c>
				<c ext="flag" form="c"/>
				<c ext="tag" form="n">
					<c ext="n" form="att"/>
					<c ext="h" form="n"/>
				</c>
				<c ext="p" form="v">
					<c ext="aux" form="v_fin"/>
					<c ext="mv" form="v_pcp"/>
				</c>
				<c ext="pv" form="p">
					<c ext="h" form="pp"/>
					<c ext="p" form="n">
						<c ext="n" form="att"/>
						<c ext="h" form="n"/>
					</c>
				</c>
			</c>
		</s>
	</p>
</data>
----end xml

The expected result XML (the changes are marked with <------):
----begin result
<data>
	<p id="p_1">
		<s id="s_1">
			<c ext="root" form="fcl">
				<group>                                  <------
					<c ext="tag" form="n">           <------
						<c ext="n" form="att"/>  <------
						<c ext="h" form="n"/>    <------
					</c>                             <------
					<c ext="tag" form="n">           <------
						<c ext="n" form="att"/>  <------
						<c ext="h" form="n"/>    <------
					</c>                             <------
					<c ext="flag" form="c"/>         <------
					<c ext="tag" form="n">           <------
						<c ext="n" form="att"/>  <------
						<c ext="h" form="n"/>    <------
					</c>                             <------
				</group>                                 <------
				<c ext="p" form="v">
					<c ext="aux" form="v_fin"/>
					<c ext="mv" form="v_pcp"/>
				</c>
				<c ext="pv" form="p">
					<c ext="h" form="pp"/>
					<c ext="p" form="n">
						<c ext="n" form="att"/>
						<c ext="h" form="n"/>
					</c>
				</c>
			</c>
		</s>
	</p>
</data>
----end result

I'm new to XSL, so I'm a little lost with it.
I've tryed to write a solution but I don't have enought knowledge to do that
:-(


Your help will be very much appreciated.

Thanks a lot,
Roger.

 
__________________________________________________________________________
Acabe com aquelas janelinhas que pulam na sua tela.
AntiPop-up UOL - I gratis!
http://antipopup.uol.com.br/

Current Thread