[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Group and filter with XSL

Subject: Group and filter with XSL
From: "contest.vix" <contest.vix@xxxxxxxxxx>
Date: Mon, 13 Dec 2004 15:29:27 -0200
filter in xslt
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.