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

RE: grouping based on string but with child nodes

Subject: RE: grouping based on string but with child nodes
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 13 Oct 2008 16:49:46 +0100
RE:  grouping based on string but with child nodes
When we've looked at this kind of problem in the past, there have generally
been two styles of solution:

(a) convert the character-markup into XML-markup, then use structural
grouping

(b) convert the XML-markup into character-markup, then use
xsl:analyze-string

In this case (a) seems a better approach. First turn "||" into <newTitle/>
elements using analyze-string, then do a group-starting-with="newTitle".

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: James Cummings [mailto:cummings.james@xxxxxxxxx]
> Sent: 13 October 2008 16:12
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  grouping based on string but with child nodes
>
> Hiya,
>
> I have some old EAD XML that I'm trying to convert to a
> slightly better form and what I want to take is something like this:
>
> <unittitle>
>     <title>Calendarial rules. Prognostics. || Alcuin,
>         <emph render="italic">Quaestiones in Genesim</emph>. ||
>         Glossaries. || <emph render="italic">Ps</emph>.-Cicero,
>         <emph render="italic">Synonyma ad Lucium
> Veturium</emph>, with added Latin-Old English
>         glossaries extracted from the Grammar and Glossary of Flfric.
>     </title>
>     <!-- other elements -->
> </unittitle>
>
> where several titles are grouped together into a single title
> element and delineated by two vertical bars || and split this
> into properly grouped elements without loss of the <emph>
> elements.  I'll be combining this with some other similarly
> split up data (about time periods of the works) into a new
> structure.  So desired output (in a variable since I then
> need to count them and create those other structures one for
> each of these) something like:
>
> <unittitle>
>     <title>Calendarial rules. Prognostics.</title>
>     <title>Alcuin, <emph render="italic">Quaestiones in
> Genesim</emph>. </title>
>     <title>Glossaries. </title>
>     <title>
>         <emph render="italic">Ps</emph>.-Cicero,
>         <emph render="italic">Synonyma ad Lucium Veturium</emph>,
>         with added Latin-Old English glossaries extracted
> from the Grammar
>         and Glossary of Flfric. </title>
>     <!-- other elements -->
> </unittitle>
>
> I've been assuming that this is a two-pass problem where I
> have to replace the '||' with some empty XML element  and
> then group-by that element?  If that is the case what is the
> best way to replace these for grouping?  Or is it possible to
> do this all-in-one?  XSLT2 solution obviously desired to
> avoid too much recursion. :-)
>
> Any suggestions?

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.