ok got a (what looks like) good answer from someone
[quoted text, click to view] oNLINE bUDDY wrote:
> How can you reverse a many-to-many XML structure between 2 tags?
>
> Lets say we have a books/author XML file.
>
> A book can have many authors.
>
> <book1>
> <Author1>
> </Author1>
> </book1>
> <book2>
> <Author1>
> </Author1>
> <Author2>
> </Author2>
> </book1>
Are you really using a unique tag name for every book and every author?
That is very bad XML design in my view, you should have one <book> and
<Author> elements and then use attributes and/or child elements to
indentify the books or the authors.
Thus an example could look like this:
<?xml version="1.0" encoding="UTF-8"?>
<booklist>
<book id="1">
<Author>Kay</Author>
</book>
<book id="2">
<Author>Kay</Author>
<Author>Gosling</Author>
</book>
</booklist>
Then you can transform that to
<?xml version="1.0" encoding="UTF-8"?>
<authorlist>
<Author>Kay<booklist>
<book id="1"/>
<book id="2"/>
</booklist>
</Author>
<Author>Gosling<booklist>
<book id="2"/>
</booklist>
</Author>
</authorlist>
with a stylesheet alike
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<authorlist>
<xsl:for-each select="//Author[not(. = following::Author)]">
<xsl:copy>
<xsl:value-of select="." />
<booklist>
<xsl:apply-templates select="//book[Author = current()]" />
</booklist>
</xsl:copy>
</xsl:for-each>
</authorlist>
</xsl:template>
<xsl:template match="book">
<xsl:copy>
<xsl:copy-of select="@*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
[quoted text, click to view] "Dimitre Novatchev" <x@yyy.com> wrote in message
news:O#3NB7RfEHA.2028@tk2msftngp13.phx.gbl...
> That solves exactly the problem you described -- in case you had something
> else in mind you have yet to tell us about it.
>
> Cheers,
>
> Dimitre Novatchev.
>
> "oNline bUDDY" <sddsdds@hotmail.com> wrote in message
> news:QvgRc.23997$Gl6.1978213@weber.videotron.net...
> > nope that wont work for what i want to do
> >
> > "Dimitre Novatchev" <x@yyy.com> wrote in message
> > news:#0#VEGOfEHA.3200@TK2MSFTNGP09.phx.gbl...
> >> The answer is to use a grouping method -- e.g. the Muenchian method.
> >>
> >> For a good description see:
> >>
> >>
http://www.jenitennison.com/xslt/grouping/ > >>
> >> or
> >>
> >>
http://www.topxml.com/code/default.asp?p=3&id=v20010129150851 > >>
> >>
> >> Cheers,
> >>
> >>
> >> Dimitre Novatchev.
> >>
> >>
> >> "oNLINE bUDDY" <oNLINEbUDDY12121212@HOTMAIL.COM> wrote in message
> >> news:2scRc.23581$Gl6.1872989@weber.videotron.net...
> >> > How can you reverse a many-to-many XML structure between 2 tags?
> >> >
> >> > Lets say we have a books/author XML file.
> >> >
> >> > A book can have many authors.
> >> >
> >> > <book1>
> >> > <Author1>
> >> > </Author1>
> >> > </book1>
> >> > <book2>
> >> > <Author1>
> >> > </Author1>
> >> > <Author2>
> >> > </Author2>
> >> > </book1>
> >> >
> >> > Many people are the authors of a book.
> >> > So if we reverse the first xml we get:
> >> >
> >> > <Author1>
> >> > <book1>
> >> > </book1>
> >> > <book2>
> >> > </book2>
> >> > </Author1>
> >> > <Author2>
> >> > <book2>
> >> > </book2>
> >> > </Author2>
> >> >
> >> > How can I do that?
> >> >
> >> > txs for your answer!
> >> >
> >> >
> >> >
> >> >
> >>
> >>
> >
> >
>
>