Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > BOOK: XSLT Programmer's Reference, 2nd Edition
|
BOOK: XSLT Programmer's Reference, 2nd Edition
This is the forum to discuss the Wrox book XSLT: Programmer's Reference, 2nd Edition by Michael Kay; ISBN: 9780764543814
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: XSLT Programmer's Reference, 2nd Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 30th, 2011, 05:44 AM
Registered User
 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting xml info from another xml stracture via xslt

I'm using XSLT 1.0 and I'm tring to make the follwing thing :

I've got a 1.xml file :

<root>
<elem1>value1</elem1>
<elem2>
<elem3>
<param1>value2</param1>
<param2>value3</param2>
</elem3>
</elem2>
<elem4>
<param3>value4</param3>
</elem4>
</root>

Now a client passes me another xml file that tells me what elements he wants me to give him back (could change between clients), i.e. :

<root>
<RequiredElements>
<elementName>elem1</elementName>
<elementName>elem2/elem3/param1</elementName>
</RequiredElements>
</root>

Which means that in this case, I should make another xml file, with this stracture:

<root>
<elem1>value1</elem1>
<elem2>
<elem3>
<param1>value2</param1>
</elem3>
</elem2>
</root>

I've tried to come up with something in xslt (no programing languages other than that) to get the stracture that I need, but couldn't make it.

Any ideas or pointers of what should I do?

Thanks for the help.
 
Old October 30th, 2011, 04:36 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You haven't actually explained the format of the output you want back, so I can't give you detailed code. But I would tackle the problem by writing a stylesheet that takes the "RequiredElements" document as input, and generates an XSLT stylesheet as output; and then run this generated stylesheet against your original XML document. This kind of approach is very often the best way of dealing with problems where an XML document acts as a specification of required processing.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding xml-html transformation of an xml string using xslt and javascript suprakash444 XSLT 1 January 12th, 2009 01:23 AM
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM
XSLT for complicated xml to xml transf. required doug@sirvisetti XSLT 3 June 17th, 2005 04:26 PM
merge two xml file and make new xml using xslt ketan XSLT 0 September 21st, 2004 08:48 AM
Merge XML files into a xml file using xslt lxu XML 4 November 6th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.