This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
The hair on the back of my neck stood up when I read your post. I can't really tell you why, but I don't like what you're doing. Apparently there's been a long debate on what should be an attribute and what should be an element. It's possible that your image data won't be XML-compliant; since you can't smack a CDATA in an attribute, it'd be nice if you could put it in an element. I'm still reeling from your "blob" comment--which of course is a SQL term, not an XML term.
Thanks for your reply. To give you an insight We have to design and xml schema for XForm based tool. 1. Data will be entered in this tool(MS Infopath or similar) and save as XML. This may contain photograph of facilities. 2. XML will be uploaded/emailed. 3. Engine needs to put data back to relational database. 4. similarly we might need to construct xml to send already entered data to be viewed in form. As it is easier for DOM parser to read information from attributes. but again I am trying to find out are their any problems in doing that. My thought is that either everything is attribute or everything is element for all table that we got in database. -- Kartik
Thanks for your reply, Lasse. Yes. I think so everything is element is safer criteria. Do you have any specific criteria's why is it more safer ? I am searching net to find out what is specific decision criteria for this. One of them certainly is blob may be incompatible with attributes as point by Nathaniel. So far I have collected following criteria we need to evaluate with regards to application that is being designed.
Is xml you are designing is human readable or machine readable ? Use elements if human readable
Use attributes if attribute readable
Is the data flat or hierarchical ?
Attributes can only hold a single level of data Elements on the other hand can have much more complex content models of theif own
Do we need to order child information item
Is it easier to transform a xml containing attributes or xml containing elements
Joined: Jan 23, 2002
Originally posted by Kartik Shah: Do you have any specific criteria's why is it more safer ?
1) You're prepared for moving from a flat structure to a hierarchy 2) You're able to use CDATA 2) (I admit this one is a bit flaky) You don't need to worry about some parser implementation assuming a given maximum size for an attribute
InfoJet Service is a Java class library to publish InfoPath Forms to the web. InfoJet Service can be deployed as Web Services. J2EE and .Net web application with integration of InfoJet Service support the users to edit InfoPath Forms in Internet Explorer and FireFox.
If you really mean a BLOB, base64 encoding is the only safe way to include binary data in an XML document. If "Large", a very large attribute may screw up XML parsers since a parser attempts to assemble all of the startElement data at once. Much safer to make a large run of text as Element content. Bill