• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can XML stylesheet "reformat" the XML content ?

 
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose I have a XML file and its schema, I want to generate a Java Object tree that is like the original XML schema but slightly different. So I guess I can use DOM or SAX to do the work. If I use JAXB or Castor I may have it problem as I want a different Object struture..

So without knowing too much about XML, here is what I am thinking --- Can I use some XML stylesheet stuff to "alter" the original XML and generate a XML that matches to my desired object struture ? If that's possible, then the second step is to use JXAB or Castor to work on the altered XML file and get the object tree. Does this make sense ?
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. However, you will have to author the modified XML Schema that JAXB needs. XSLT will only transforms documents (transformation of the XML Schema would require a separate XSLT � there is no point to that).

For an intro to XSLT see sample chapter 15 from Elliotte Rusty Harold's XML 1.1 Bible.

Writing complex style-sheets can be difficult as XSLT is more like a functional programming (FP) language (rather than procedural or object-oriented). Also it is easy to produce transforms that do not perform well (until you start thinking in FP terms)
 
reply
    Bookmark Topic Watch Topic
  • New Topic