How to transform an XML file
Consider an XML file that contains information about books: their titles and publishers.
<?xml version="1.0" encoding="iso-8859-1" ?>
<Books>
<Book>
<Title>Beginning XML</Title>
<Publisher>Wrox</Publisher>
</Book>
<Book>
<Title>XML Step by Step</Title>
<Publisher>MSPress</Publisher>
</Book>
<Book>
<Title>Professional XML</Title>
<Publisher>Wrox</Publisher>
</Book>
<Book>
<Title>Developing XML solutions</Title>
<Publisher>MSPress</Publisher>
</Book>
</Books>
You may want to create an XML file with another structure that should contain data about publishers and the books published by them.
- Design a workflow with AutoCapture, XML Importer and XML Generator components.
-
On the Fields tab of the XML Importer configuration, add two search fields.
Example
- Wrox_books with corresponding XPath query: //Publisher[.= "Wrox"]/parent::node()/Title
- MSPress_books with corresponding XPath query: //Publisher[.= "MSPress"]/parent::node()/Title
The following RRTs will be built:- ~XIM::Wrox_books%~ is replaced by "Beginning XML".
- ~XIM::Wrox_books_1%~ is replaced by "Beginning XML".
- ~XIM::Wrox_books_2%~ is replaced by "Professional XML".
- ~XIM::MSPress_books%~ is replaced by "XML Step by Step".
- ~XIM::MSPress_books_1%~ is replaced by "XML Step by Step".
- ~XIM::MSPress_books_2%~ is replaced by "Developing XML solutions".
-
In XML Generator configuration, use the following template and use RRTs from XML Importer in the node values of this template.
Example
<?xml version="1.0" encoding="iso-8859-1" ?> <Publishers> <Publisher Name="Name1"> <Book>Title</Book> <Book>Title</Book> </Publisher> </Publishers>
- Run the process.
- Send the XML file to the process by AutoCapture client.
The following XML file will be created:
<?xml version="1.0" encoding="iso-8859-1" ?>
<Publishers>
<Publisher Name="Wrox">
<Book>Beginning XML</Book>
<Book>Professional XML</Book>
</Publisher>
<Publisher Name="MSPress">
<Book>XML Step by Step</Book>
<Book>Developing XML solutions</Book>
</Publisher>
</Publishers>