This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Is this about grouping ?


> >Here is my problem ( newbies question ).
> >My original source is like this :
> >
> ><?xml version="1.0"?>
> ><topic>
> >    <element1>text1</element1>
> >    <element2>text2</element2>
> >    <element3>text3</element3>
> >    <element4>text4</element4>
> >
> >    <element1>text1</element1>
> >    <element2>text2</element2>
> >    <element3>text5</element3>
> >    <element4>text6</element4>
> ></topic>
> >
> >I would like to transform it into :
> >
> ><?xml version="1.0"?>
> ><topic>
> >    <element1>text1</element1>
> >    <element2>text2</element2>
> >        <element3>text3</element3>
> >        <element4>text4</element4>
> >        <element3>text5</element3>
> >        <element4>text6</element4>
> ></topic>

Yes, this is definitely a grouping problem, and quite a tricky one, I
imagine. Will the grouping key always be element1+element2, or might it be a
sequence of elements of any length? If the latter, it might be best to treat
it as a recursive grouping problem: group first on things with a common
element1, then within that, those with a common element2, and so on.

Is the number of element names (element1..element4) fixed or variable?
Either way I'd suggest starting by transforming <element1> into <element
level="1">, this will make it much easier to apply the same code at each
level.

It might also be a good idea to start by adding a grouping element around
each sequence <element1>..<element4>.

I'm not sure why you want the output indentation. This suggests there is a
structure in the output that's meaningful to the human reader. If that's the
case, then it's probably meaningful to software as well, so include an extra
element in the output structure to represent each "indentation level". Once
you've done that, xsl:output indent="yes" will display it the way you want.

To summarize: I think you need to tackle this problem as a sequence of
transformations, it's too complex to do as a single step.

Mike Kay
Software AG
> >
> >As you see, the common element are <element1> and <element2>.
> >My questions are :
> >1. as I'm really new to XSLT, is this related to multi-pass issue or
> >grouping issue
> >   ( Muenchian, Kaysian, etc ) ?
> >2. how can I generate a correct indentation in the result
> tree ( XML output
> >) as above ?
> >   I mean how is it possible for me to generate, say, for
> that element the
> >indentation is
> >   4 chars ( 1 tab ), but for that element is 8 chars ( 2 tabs ) ?
> >
> >If you find my questions are too basics, rather than suggest
> me to read the
> >on-line tutorials,
> >buy those XSLT books, etc, please ignore my questions.
> >If you think that we can advice, guide, and learn each
> others, I appreciate
> >that.
> >
> >Thanks,
> >Benoit Aumars.
> >
> >
> >
> >************************************************************
> >JLT Management Services Limited
> >6 Crutched Friars, London EC3N 2PH. Co Reg No 1536540
> >Tel: (44) (0)20 7528 4000   Fax: (44) (0)20 7528 4500
> >http://www.jltgroup.com
> >------------------------------------------------------------
> >The content of this e-mail (including any attachments) as
> >received may not be the same as sent. If you consider that
> >the content is material to the formation or performance of
> >a contract or you are otherwise relying upon its accuracy,
> >you should consider requesting a copy be sent by facsimile
> >or normal mail.  The information in this e-mail is
> >confidential and may be legally privileged. If you are not
> >the intended recipient, please notify the sender immediately
> >and then delete this e-mail entirely - you must not retain,
> >copy, distribute or use this e-mail for any purpose or
> >disclose any of its content to others.
> >
> >Opinions, conclusions and other information in this e-mail
> >that do not relate to the official business of JLT
> >Management Services Limited shall be understood as neither
> >given nor endorsed by it.  Please note we intercept and
> >monitor incoming / outgoing e-mail and therefore you should
> >neither expect nor intend any e-mail to be private in nature.
> >
> >We have checked this e-mail for viruses and other harmful
> >components and believe but not guarantee it virus-free prior
> >to leaving our computer system.  However, you should satisfy
> >yourself that it is free from harmful components, as we do
> >not accept responsibility for any loss or damage it may
> >cause to your computer systems.
> >************************************************************
>
>
> --
> ======================================================================
> B. Tommie Usdin                        mailto:btusdin@mulberrytech.com
> Mulberry Technologies, Inc.
> http://www.mulberrytech.com
> 17 West Jefferson Street                           Phone: 301/315-9631
> Suite 207                                    Direct Line: 301/315-9634
> Rockville, MD  20850                                 Fax: 301/315-8285
> ----------------------------------------------------------------------
>   Mulberry Technologies: A Consultancy Specializing in SGML
> and XML
> ======================================================================
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]