• XML Concept: Well Formed
  • Case Sensitivity
  • No Overlapping Tags
  • Microsoft Word Applied xml a toolkit for Programmers Wiley doc




    Download 2,96 Mb.
    Pdf ko'rish
    bet59/131
    Sana14.05.2024
    Hajmi2,96 Mb.
    #232039
    1   ...   55   56   57   58   59   60   61   62   ...   131
    Bog'liq
    Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers

    XML Documents in Depth
    Now that we’ve had a brief introduction to the overall structure of an XML system, let’s 
    start breaking things down into greater detail.
    XML documents are logical, hierarchically structured information chunks. Recall our 
    analogy of XML documents as blueprints from 
    Chapter 1
    . XML documents are not 
    solutions in themselves. Remember, unlike HTML documents whose specific purpose is 
    the display of information, XML documents have the agenda of presenting information so 
    that it can be further processed. Therefore, an XML document includes a lot of markup to 
    describe the content (raw information) it contains.
    XML Concept: Well Formed
    In 
    Chapter 1
    , we briefly touched upon the concept of well formed XML documents. Well 
    formed XML documents are those XML documents that are syntactically correct. XML, 
    unlike HTML, is extremely picky about syntax. Fortunately, it’s not that hard to write 
    syntactically correct XML. The following are general guidelines for writing well formed 
    XML documents.
    Case Sensitivity
    Unlike HTML, XML is case sensitive. You must be very careful when writing markup. 
    Spelling mistakes can sometimes take a long time to detect, especially if you are using a 
    plain text editor for creating your XML document. 
    Closing Tags
    Another thing that the XML specification is rather picky about is that every open tag must 
    be closed. So, though it’s quite acceptable to begin an HTML document with an  
    tag and to not bother to close it, an XML parser will set off all kinds of red flags for not 
    closing a tag.
    No Overlapping Tags
    It is easy to confuse overlapping tags with nesting tags. 
    Nesting tags
    is a way of 
    developing a logical hierarchy of information similar to the BODMAS (brackets of division, 
    multiplication, addition, subtraction—wouldn’t our teachers be proud of us for 
    remembering?) rules of eighth grade math. Nesting tags in XML documents is fine and is 
    strongly encouraged from a design perspective. However, you cannot overlap tags. 
    Here’s an example of an XML clip that contains nested tags:


    Contents of third tag


    There is a hierarchy that is implicitly defined by the above structure.
    Here’s an example of an unacceptable (that is, not well formed) XML snippet with 
    overlapping tags.



    Contents of third tag


    - 54 -

    The term 
    overlapping
    means that a tag that is not a child of the first starts before the 
    other ends. Do you see how in the above case that an overlap occurs between 

    and 

    ? In the XML world, this is a definite no-no. For those 
    of you who are experienced in HTML, this may seem a little inconvenient; after all, most 
    HTML parsers don’t care when you overlap (they just act weird when you overlap tags). If 
    you think about it for a minute from the parser’s perspective, however, things could get 
    very confusing with overlapping tags. If you intend to write your XML own documents, we 
    strongly encourage you to watch out for overlapping tags.
    Several tools out in the market take care of fussing around with the markup syntax. Tools 
    like Vervet Logic’s XML Pro and Microsoft’s XML Notepad allow you to visually create 
    your structures and fill in content. The advantage of these programs is obvious; you don’t 
    have to worry about well formed nonconformities. However, we must forewarn you that 
    should you use any of these programs (or ones similar to these), you may end up losing 
    several degrees of flexibility in your documents (for example, XML Notepad doesn’t let 
    you work with processing instructions very easily). For an updated list of tools for editing 
    XML documents, check out this book’s companion Web site.

    Download 2,96 Mb.
    1   ...   55   56   57   58   59   60   61   62   ...   131




    Download 2,96 Mb.
    Pdf ko'rish

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Microsoft Word Applied xml a toolkit for Programmers Wiley doc

    Download 2,96 Mb.
    Pdf ko'rish