Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

need help on Converting XML to XML

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi just wanna know how to convert XML to XML.
The reason why I want to do this is I need to further process
the XML that I've fetched from the backend. I want to modify my original XML whenever client side events. Can an XSLT to this transformation, ive tried to but doesn't work, even though I try to transform it still gives me the original XML. If i cant do this they my last resort is to use DOM API in the client app to do the transformation.
Thanks for your help
Richard
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard, you can use XSLT for �XML to XML� transformation, it�s what XSLT is for . Maybe you just have problem with saving the result? What software do you use for XSL transformations?
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the modifictions on your XML is not pre-defined and are driven by user events, then it will be hard to use XSLT. Remember XSLT translates one XML to another only if you know the rules of transformation( aka the XSL or stylesheet ) before hand.
Not very long ago I too was in a similar situation. The requirement was to maintain an in-memory XML that undergoes transformations driven by the user. Imagine an in-place editing of various XML nodes in no particular order. After series of such transformations ( again driven by an user event, say pressing on the "DONE" button ) the resulting document should be persisted.
The ideal approach would be to use DOM. Manipulate the nodes of the tree according to your rules and when you're done, persist the DOM. The major pitfall of DOM is that it doesnot have any facility to "write" XML documents. So the trick is to generate output XML documents from a DOM tree using a dummy transformation.
Hope that helps( and is clear as mud )
Let me know if you need further clarification...
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajith, when I said about doubled traffic, you probably thought I was joking... Never mind.
Being an extremely lazy creature, I'll try to insist on XSLT use.
You can change their output dynamically by:
1) having a few predefined XSLT stylesheets and choosing one of them on proper event;
2) using XSLT Extension Functions. Although they are W3C compliant, you can use them only if your XSLT processor supports them. Xalan claims to support extension functions written in JavaScript (as well as in few other languages), you can find more details here: http://xml.apache.org/xalan-j/extensions.html
3) modifying your XSLT stylesheet (which is an XML document) in memory, although this is probably not better than simply use DOM to parse and modify XML source itself.
Generally, my understanding is: if your modifications do not affect the entire XML document and are not based on complex logic, then you can you XSLT. Otherwise, you are doomed to DOM !
Ajith, I just help you to confuse Richard...
[This message has been edited by Mapraputa Is (edited April 20, 2001).]
 
Richard Pamatmat
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the advice I've got one more problem.
You see Im using IE5 with the MSXML parser built in.
I managed to manipulate my xml tree using the DOM.
But I'm dont how to tell my browser to display this new XMLDOM object as xml. I've managed to display my modified xml tree but as html.
Thanks...
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe this example can help: http://www.xmlpitstop.com/Examples/WebWorkShop/Multiple_views/multiple.htm
You can look at the code in http://www.xmlpitstop.com/Examples/WebWorkShop/Multiple_views/controls.htm
to see how it works
 
Richard Pamatmat
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it workin! Thanks Guys!
Ur the best!!

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!