Transfer one xml to another
Now I have two xml file. I would like transfer the first XML to the second XML.
The difference between these two xml files is: the above xml is to just list book information, like its first author, 2rd author, book name, etc. The second xml is a result XML file grouped by first author, author1.
The below xml has an attribute, "Author". All books, whose first author is "Mike", in the above xml is grouped into one block in the below xml; all books, whose first author is "Nancy", is gouped into another block in the below xml; ....
How can I use XSLT to complete it? Thanks a lot.
First xml :
<BookStore>
<Books>
<Book>
<BookAuthors>
<Author1>Mike</Author1>
<Author2>Tome</Author2>
<Author3>Jane</Author3>
</BookAuthors>
<BookName>BookName1</BookName>
<BookType>Math</BookType>
</Book>
<Book>
<BookAuthors>
<Author1>Mike</Author1>
<Author2>Gary</Author2>
<Author3>Henry</Author3>
</BookAuthors>
<BookName>BookName2</BookName>
<BookType>Physics</BookType>
</Book>
<Book>
<BookAuthors>
<Author1>Nancy</Author1>
</BookAuthors>
<BookName>BookName2</BookName>
<BookType>Physics</BookType>
</Book>
</Books>
</BookStore>
Second xml:
<BookStore>
<BookFirstAuthor FirstAuthor="Mike">
<Book>
<BookAuthors>
<Author1>Mike</Author1>
<Author2>Tome</Author2>
<Author3>Jane</Author3>
</BookAuthors>
<BookName>BookName1</BookName>
<BookType>Math</BookType>
</Book>
<Book>
<BookAuthors>
<Author1>Mike</Author1>
<Author2>Gary</Author2>
<Author3>Henry</Author3>
</BookAuthors>
<BookName>BookName2</BookName>
<BookType>Physics</BookType>
</Book>
</BookFirstAuthor>
<BookFirstAuthor FirstAuthor="Nancy">
<Book>
<BookAuthors>
<Author1>Nancy</Author1>
</BookAuthors>
<BookName>BookName3</BookName>
<BookType>Physics</BookType>
</Book>
</BookFirstAuthor>
</BookStore>
|