XML Simplified

  • Vasant Raj

    SSCommitted

    Points: 1835

    Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/rVasant/xmlsimplified.asp

  • Kathy Collins

    SSC Enthusiast

    Points: 141

    Aha!  I always wondered but have been so entrenched in "business as usual" that I just didn't take the time.  All the other articles I tried to read while taking a relax break made assumptions that I already knew something about XML.  Thank you for this simple explanation.

  • Jonathan Stokes

    SSCrazy Eights

    Points: 9861

    I thought your article was simplified and made easy reading. Hiowever, you did miss out on some of the limitations of xml.

    The main limitation being that xml cannot handle relational data or multiple children.

    You cannot stored relational data in a xml format. If you want to query acroess a relational set, you need to bring xml into a table or equivalent to be able to do so.

    Secondly, and I think more importantly, the issue of multiple children. If you have more than one child, xml will not allow you store it. Take for example a company organisational hierarchy. At the root you would have CEO for instance. Then if you have 5 people underneath, all the same level you get the problem of having to tag them all together. Then you cannot go down any more paths with the 5 people tagged together.

    XML can only handle one single record all with single values, in the manner that you gave in your sample. What would happen if you had 2 authors. You would need another line like <FNAME>Surname2</FNAME> and the xml would not parse without errors.

    Oh, almost forgot. Cannot use characters likle ampersand in xml document or it will not parse.


    ------------------------------
    The Users are always right - when I'm not wrong!

  • Parker Smith

    Mr or Mrs. 500

    Points: 591

    I have a pedantic point - XML is not a language, per se.

    It is a standard for specifying how to put data into a text file.

    XML is not any kind of a replacement for HTML - it is, instead, a standard that can be used for creating a specification for (for example) a version of HTML (and is currently being used for that very purpose).

    HTML code can then be checked against the XML-based specification in an automated manner, without ambiguity.

    The confusion comes from XML's unfortunate name (XMS would have made things clearer, I think), and the fact that it operates at a higher level of abstraction than most people typically work at.

  • Kenneth Lee

    Ten Centuries

    Points: 1263

    This article has a few typos.  It says:

    The next line describes the root element of the document (like it was saying: "this document is a article") i.e., “ARTICLE”.

    The next lines describe the child elements of the root (TITLE, DATE, AUTHOR, SUMMARY, and CONTENT).

    Each element can also have child’s i.e. AUTHOR has FNAME and LNAME.

    But the example XML file has a root of “ARTICLES”.  There is one child “ARTICLE” in the root and then the next lines decribe child elements of the “ARTICLE” element.

    In the XPATH example it says:

    ARTICLE[DATE = "05/16/2005"]     - All <DATE> elements which has at least one <DATE> child-element child with the value "05/16/2005".

    Should say ARTICLE[DATE = "05/16/2005"]     - All <ARTICLE> elements...

    Since this article is directed towards SQL people, a big point to make is that elements are case sensitive.

    <ARTICLE>This is NOT XML and will not be accepted as well formed.</Article>

  • Kenneth Lee

    Ten Centuries

    Points: 1263

    Jonathan Stokes says you can't have multiple children and XML is not relational.  Both very wrong statements.  You can have only one root element.  So in the example <ARTICLES> is the only element that can't be repeated.  You can have as many <ARTICLE> children inside of the root as you want.  The XPATH statements in the article include examples of relational selections.

    Admittedly the DOM model used by Explorer has a relational setup that sucks, but it does have one.  I sure wouldn't use it to relate table structures, but it can be done.  (Whether you get an answer this year is another question.)  There are other DOM models that work quite well at doing relationships.

  • Vasant Raj

    SSCommitted

    Points: 1835

    Sorry about the sturcture of XML. The <ARTICLES> tag allow you to encompass multiple <ARTICLE> tags. That's why it has been added.

    Also the mistake in the XPATH would be rectified soon.

    Read "Important Instructions" for case-sensitive part.

    thnx.

  • Jonathan Stokes

    SSCrazy Eights

    Points: 9861

    Not wanting to get into an argument here, Kenneth, but I stand by my point and hope to clarify a little more.

    If you have multiple authors with a first name and last as in the scenario I would want to structure as follows:

    <author>

    <firstname>john1</firstname>

    <lastname>smith1</lastname>

    </author>

    <author>

    <firstname>john2</firstname>

    <lastname>smith2</lastname>

    </author>

    I attempted to run this using word 2003 xml editor and it would not generate the xml beacuse of duplicate elements. I could do this:

    <author>

    <firstname>john1,john2</firstname>

    <lastname>smith1,smith2</lastname>

    </author>

    This does not help at all because I need to put a lot of work in to get the data in and back out. To import into a table I need to loop around within the tag, also. I also need to have a definite character seperator at all times.

     


    ------------------------------
    The Users are always right - when I'm not wrong!

  • Vasant Raj

    SSCommitted

    Points: 1835

    You can have multiple authors of a book by using the following structure.

    <book>

           <author>

                <firstname>john1</firstname>

                <lastname>smith1</lastname>

           </author>

           <author>

                <firstname>john2</firstname>

                <lastname>smith2</lastname>

           </author>

    </book>

  • Scott D. Smith

    SSC Veteran

    Points: 278

    I used to work at Spyglass, where the Mosaic web browser was invented (and ultimately sold to Microsoft). A few points: 1) HTML is, indeed, a specific instance of XML. 2) You CAN have multiple authors for a book just as described. 3) XML is more of a heirarchical database structure because the data is held in files rather than columnar tables and you must "traverse" the files via nodes to access the data, 4) XML can be slurped into a database (SQL Server, for instance) for faster performance. But by itself, XML sitting in files is not a fast way to access and manipulate data.

    scott

  • Jonathan Stokes

    SSCrazy Eights

    Points: 9861

    I know you can put it into the format as shown, but...

    If you use the xml template generator in word 2003 you get real problems. Try out this link:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_wd2003_ta/html/odc_wdxmlresumetemp.asp

    The main point here is that you need to create an xslt template to map the document to generate xml. Because it sees the tag <author> once only in the xslt template, it will error.

    if you put the author tag in twice then it works. The problem is you do not know how many author tags you require.

    It adds a little more weight to my argument that xml is not really a conventional standard at all. The applications to retrieve xml have to be written specifically for each template. I thought the idea of a standard was someting like a text file that you can dts in, open in excel etc.


    ------------------------------
    The Users are always right - when I'm not wrong!

  • Carlos Urbina

    SSCommitted

    Points: 1850

    Thank you for taking the time to help the rest of us.

  • Stephen Hirsch

    SSCommitted

    Points: 1822

    Richard Saul Wurman used to say "Clarify, Don't Simplify". This article proves that point. It is simplified to the point of distortion.

    1) XML is nothing in and of itself. It is a metalanguage; i.e., if you want to make a markup language, if you do it this way, then it is XML.

    2) Everything depends on your instantiation of XML. In other words, the DTD or Schema that is used is much more critical to the success of your efforts than the various tools mentioned in the article. Designing the DTD/Schema (i.e., the data model) is almost never mentioned, yet that is so much harder to do right than anything else.

    3) XML is a lousy data store. It biases towards a hierarchical data structure, which went out of style in the 1980's for a reason. It's incredibly bloated (I remember file sizes 43x the size of the same data stored in a flat file), and the pre-built infrastructure pales in comparison to relational databases.

    4) What infrastructure is there is very immature, even after all these years. I was working on the FDA's SPL initiative, which was based on an XML Schema. XML Spy compiled the schema as an XML file, while another tool found errors in the schema as a schema. What good is that?

  • suresh.patha

    SSC Journeyman

    Points: 75

    Hi ....

    In this article you have mentioned how to use CDATA..

    I am using while CDATA for inserting ..

    could you plese tell how to use CDATA for retrieving

    ex:INSERT INTO HELLO VALUES( ' ')

    but in the table it is stored as &

    how to show to user a &

    Thanks

  • suresh.patha

    SSC Journeyman

    Points: 75

    Hi ....

    In this article you have mentioned how to use CDATA..

    I am using while CDATA for inserting ..

    could you plese tell how to use CDATA for retrieving

    ex:INSERT INTO HELLO VALUES( ' ')

    but in the table it is stored as &

    how to show to user a " &"

    Thanks

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic. Login to reply