Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to use XSLT to transform XML according to the data in another XML

Reply
Thread Tools

How to use XSLT to transform XML according to the data in another XML

 
 
ai2003lian@yahoo.com
Guest
Posts: n/a
 
      02-02-2005
I have a XML containing more information than required. And I want to
transform it to a XML with less information according to the
requirement data in another XML. How could I accomplish this using
XSLT?

Here're the XML files:

source.xml :

<AllFields>
<field name="f1", type="N">value1</field>
<field name="f2", type="N">value2</field>
<field name="f3", type="N">value3</field>
<field name="f4", type="N">value4</field>

....
</AllFields>

requirement.xml :

<requiredFields>
<field>f1</field>
<field>f3</field>
</requiredFields>

result.xml :

<AllFields>
<field name="f1", type="N">value1</field>
<field name="f3", type="N">value3</field>
</AllFields>

Thanks in advance!

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      02-02-2005
Tempore 17:58:33, die Wednesday 02 February 2005 AD, hinc in foro {comp.text.xml} scripsit <(E-Mail Removed)>:

> I have a XML containing more information than required. And I want to
> transform it to a XML with less information according to the
> requirement data in another XML. How could I accomplish this using
> XSLT?

Hi,


Here's one approach:

<xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="AllFields">
<xsl:copy>
<xsl:copy-of select="field[@name=document('requirement.xml')/*/field]"/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>


regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Vincit omnia simplicitas
Keep it simple
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transform XML to XML using XSLT adi XML 1 06-06-2006 01:06 AM
Transform XML string using XSLT file Isambella via DotNetMonster.com ASP .Net 4 08-02-2005 07:19 AM
blocking I/O with javax.xml.parsers.DocumentBuilder.parse() and javax.xml.transform.Transformer.transform() jazzdman@gmail.com Java 1 03-27-2005 06:56 AM
How to use XSLT to transform XML according to the data in another XML ai2003lian@yahoo.com XML 0 02-02-2005 04:57 PM
Transform XML using XSLT based on element position Igor XML 1 07-20-2003 08:16 PM



Advertisments