xsl-list
[Top] [All Lists]

Group and filter with XSL

2004-12-13 10:29:27
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 - É grátis!
http://antipopup.uol.com.br/



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>