• 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

Data Binding Tools/API's

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With data binding tools like Castor and Breeze XML Binder, is there any reason to directly use SAX and DOM parsers anymore?
From what I can tell, going from DB->Objects->XML, and XML->Objects->DB can all be accomplished rather easily with the data binding facilities which automatically generate classes from schemas and provide a framework to marshall/unmarshall.
Everybody is still talking about using parsers directly, so perhaps I am way off base.
Can someone please clarify these issues for me.
Thanks in advance.
Rob
 
Rob Levo
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any thoughts on this one?
Thanks,
Rob
 
Rob Levo
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some help here would be appreciated. Need to clear up this point in my head.
 
Rob Levo
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this is an important question.
Can someone please help.
Thanks again.
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Rob, I'm not familiar with those tools so I don't know what great advantage you see in using them.
It's my philosophical position that tools don't "invalidate" other tools, except in the mind of the individual user. Asking "do we really need a parser" for me presumes opinions I don't agree with at the start, so it's hard for me to understand what kind of clarification you're looking for.
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, this is an important question. I was thinking about it last three days and did not feel that I can give satisfactory answer either. Was waiting for somebody with more practical experience to answer.
In my understanding, parsers are more "generic" tools. They operate on level of "elements", "attributes" etc. So you program would go like this: "Give me the root element. What is its name, by the way? Now give me all its immediate descendants. Is there an element with "sock" in its name?" You can process any XML document in this manner.
With binding APIs you have one particular type of XML documents, defined by DTD or Schema. These tools generate set of Java classes; roughly speaking elements are translated into classes and attributes into private fields. Then you compile these classes and now you can talk to your XML in terms of your object model, so instead of
currentElement.setAttributeValue("price", 10)
you can say:
sock.setPrice(10)
(warning: first example is contrived and employ neither DOM nor SAX syntax )
In both cases an input document has to be parsed, so I do not think the second model offers any improvement in efficiency. It frees you from learning DOM/SAX API, though.
Bottom line: XML is often defined as a meta-language to define domain-specific languages. In this model parsers are meta-tools to deal with this meta-language. Any particular instance of XML, however, isn't a meta-language. It uses limited vocabulary, and binding frameworks are tools to deal with these specific languages of limited vocabulary.
When would you use parser? Perhaps if you have too many different kinds of XMLs, so it's not sensible to have predefined set of classes for them. Or you do not know in advance what these XML documents can be, so you have to apply generic processing. Mapping one known database to XML fits none of these scenarios
Does it help?
[ February 12, 2002: Message edited by: Mapraputa Is ]
 
Rob Levo
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mapraputa Is:
Yes, this is an important question. I was thinking about it last three days and did not feel that I can give satisfactory answer either. Was waiting for somebody with more practical experience to answer.
In my understanding, parsers are more "generic" tools. They operate on level of "elements", "attributes" etc. So you program would go like this: "Give me the root element. What is its name, by the way? Now give me all its immediate descendants. Is there an element with "sock" in its name?" You can process any XML document in this manner.
With binding APIs you have one particular type of XML documents, defined by DTD or Schema. These tools generate set of Java classes; roughly speaking elements are translated into classes and attributes into private fields. Then you compile these classes and now you can talk to your XML in terms of your object model, so instead of
currentElement.setAttributeValue("price", 10)
you can say:
sock.setPrice(10)
(warning: first example is contrived and employ neither DOM nor SAX syntax )
In both cases an input document has to be parsed, so I do not think the second model offers any improvement in efficiency. It frees you from learning DOM/SAX API, though.
Bottom line: XML is often defined as a meta-language to define domain-specific languages. In this model parsers are meta-tools to deal with this meta-language. Any particular instance of XML, however, isn't a meta-language. It uses limited vocabulary, and binding frameworks are tools to deal with these specific languages of limited vocabulary.
When would you use parser? Perhaps if you have too many different kinds of XMLs, so it's not sensible to have predefined set of classes for them. Or you do not know in advance what these XML documents can be, so you have to apply generic processing. Mapping one known database to XML fits none of these scenarios
Does it help?
[ February 12, 2002: Message edited by: Mapraputa Is ]


Thank you both for your replies.
Mapraputa,
I believe you verified what I was thinking and added some details that I had not completely thought out. I will paraphrase my understanding of what you said to see if I understand correctly.
The binding tools are a big help in speeding development by automatically creating classes from schemas or DTD's, (even database schemas) and generating the code to do the marshalling/unmarshalling. The tools also save the novice, like me, from learning the details of SAX and/or DOM.
There are some cases when the parsers should be used directly like when you don't know in advance the struture of the XML doc.
I have to recommmend a solution for a project, and I want to have all the information and give the best possible answer.
Did I get it right?? Want to make sure I am not
Thanks again,
Rob
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The binding tools are a big help in speeding development by automatically creating classes from schemas or DTD's, (even database schemas) and generating the code to do the marshalling/unmarshalling. The tools also save the novice, like me, from learning the details of SAX and/or DOM.
There are some cases when the parsers should be used directly like when you don't know in advance the struture of the XML doc.

I believe this is true.
This paper has a nice overview of XML binding (they call it "JAXB") vs. XML parsing (aka JAXP)
Quote:
"Use JAXB when you want to:
* Access data in memory, but do not need tree manipulation capabilities
* Process only data that is valid
* Convert data to different types
* Generate classes based on a DTD
* Build object representations of XML data.
Use JAXP when you want to:
* Have flexibility with regard to the way you access the data: either serially with SAX or
* randomly in memory with DOM
* Use your same processing code with documents based on different DTDs
* Parse documents that are not necessarily valid
* Apply XSLT transforms
* Insert or remove objects from an object tree that represents XML data"
Also, I have to say that other sources said generated classes *are* faster than old good parsing. I do not quite understand why, but it doesn't make my opponents view incorrect
 
Rob Levo
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mapraputa Is:
The binding tools are a big help in speeding development by automatically creating classes from schemas or DTD's, (even database schemas) and generating the code to do the marshalling/unmarshalling. The tools also save the novice, like me, from learning the details of SAX and/or DOM.
There are some cases when the parsers should be used directly like when you don't know in advance the struture of the XML doc.

I believe this is true.
This paper has a nice overview of XML binding (they call it "JAXB") vs. XML parsing (aka JAXP)
Quote:
"Use JAXB when you want to:
* Access data in memory, but do not need tree manipulation capabilities
* Process only data that is valid
* Convert data to different types
* Generate classes based on a DTD
* Build object representations of XML data.
Use JAXP when you want to:
* Have flexibility with regard to the way you access the data: either serially with SAX or
* randomly in memory with DOM
* Use your same processing code with documents based on different DTDs
* Parse documents that are not necessarily valid
* Apply XSLT transforms
* Insert or remove objects from an object tree that represents XML data"
Also, I have to say that other sources said generated classes *are* faster than old good parsing. I do not quite understand why, but it doesn't make my opponents view incorrect


Thanks again, tremendous help!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic