Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML 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 April 9th, 2011, 04:53 PM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default create XML using XPath and XSL

Hi ,

Please let me know if I can create XML using Xpath list and run time values for those elements and how can i use XSL as starting point for this task. Also I want to create this xml from scratch.(empty document).

Thank you.

Last edited by sonaliag1; April 9th, 2011 at 04:58 PM..
 
Old April 9th, 2011, 06:42 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 made yourself at all clear. It would help to give sample input and desired output. XPath is normally used for reading XML, not for writing it.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 10th, 2011, 02:03 AM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default create XML using XPath and XSL

Hi,

I have map of xpath and corresponding text values.
So I want to use the xpath as key to get values from map and also use that xpath in node creation. Is there any API that I can use in Java to create nodes directly by passing xpath string?
like - domDoc.createElement(xPathString,value);

sample HashMap:

{
/rootNode/mainNode/element1 = "element1 text",
/rootNode/mainNode/element2 = " ",
/rootNode/mainNode/element2/element3 = "element3 text",
---and so on
}

After creating these elements I want to match them with XSL and output final XML document. So how this matching of Xptah in XSL could be done ?

The final output will be like:

<rootNode>
<mainNode>
<element1>element1 text </element1>
<element2>
<element3>element3 text</element3>
</element2>
</mainNode>

---- other mainNodes with different text values
</rootode>

Also there will be multiple mainNode s with different run time values for the elements.

Or is there a way to match XSL with Xpath and generate final elements as per XSL directly , instead of first creating them and again outputting in sequence specified in XSL.

Thank you.
 
Old May 24th, 2011, 06:35 AM
Registered User
 
Join Date: May 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default xpath and xsl

There is a similar question posted here which I think might help, http://stackoverflow.com/questions/6...ent-node-value

Let me know if it helps, you could also try using an xml editor to see if that helps your workflow, it's fairly good for validation of your xsd or xml file as well.





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL/XPATH namespace issue caltech XSLT 2 April 26th, 2010 11:31 AM
create xml document by xpath in java zhebincong XML 1 October 6th, 2009 04:07 AM
XSL Param with XPath expressions V4mp1r3 XSLT 7 June 1st, 2007 11:47 AM
chapter4 xsl and xpath problem clinfix BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 August 8th, 2006 02:21 PM
XSL:CHOOSE & XPATH falmouth XSLT 3 November 17th, 2004 08:36 AM





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