Re: Grouping by attribute
<quote> tags were occuring inside <p> tags, which they are not allowed to do. Initially <quote> tags are the only thing I need to move out of <p>. So: <body> <!-- case 1 --> <p>text<p> <!-- case 2 --> <quote> text <p>text</p> text <span>text</span> </quote> <!-- case 3 --> <p><quote>text</quote></p> <!-- case 4 --> <p> text <quote>text</quote> text <span>text</quote> text </p> </body> should become: <body> <!-- case #1 --> <p>text</p> <!-- case #2 --> <quote> text <p>text</p> text <span>text</span> </quote> <!-- case #3 --> <quote>text</quote> <!-- case #4 result #1 --> <p>text</p> <quote>text</quote> <p> text <span>text</span> text </p> </body> I'm not sure if the last p actually turns into three p's: <!-- case #4 result #2 --> <p>text</p> <p><span>text</span></p> <p>text</p> Result #1 would be best, but result #2 this is also acceptable. I'll check tomorrow what is actually happening. In any case, it validates against the DTD used and the result is working as expected. -Jostein 2009/10/21 Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> > > Jostein, > > At 08:33 AM 10/21/2009, you wrote: >> >> Nice. I modified it slightly for the more complex structure of the >> actual XML, but you essentially solved it. > > But ... as so often, the problem as specified is just the tip of what could be a much larger iceberg. > > What if your data has > > <p> > text <span>more text</text> text > <quote>text</quote> > text > <quote>text</quote> > text > </p> > > What do you want to happen then? > > By generating p elements only when you match "text()[parent::p]" (or, equivalently, "p/text()"), you succeed in splitting out all the text node children of p from their sibling elements. But your problem specification didn't actually say this was what you wanted to do -- and the problem of splitting only some of the elements is at least as common. > > For that problem, you do in fact want to use grouping. (And I think it came up quite recently on the list). > > Cheers, > Wendell > > > > ====================================================================== > Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx > Mulberry Technologies, Inc. http://www.mulberrytech.com > 17 West Jefferson Street Direct Phone: 301/315-9635 > Suite 207 Phone: 301/315-9631 > Rockville, MD 20850 Fax: 301/315-8285 > ---------------------------------------------------------------------- > Mulberry Technologies: A Consultancy Specializing in SGML and XML > ======================================================================
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format