Results 1 to 7 of 7

Thread: XML Document Using XML Schema?{rep points included!}

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Resolved XML Document Using XML Schema?{rep points included!}

    This seems very confusing to me so i am hoping that someone might be able to clarify.

    Im reading an old book (June 2000) on XML so i don't know if this is still the way to do things. The book shows the following lines. I understand that the first line is a PI instruction to the XML parser. Now the second is the xml schema instance. Third is the xml doc namespace and the forth is the location of the xml schema doc .xsd. Now why is it needed that a namespace be defined for the schema? I understand namespaces as they relate to xml elements but is it the same for the schema,
    to avoid collisions? Thanks.
    Code:
    <?xml version="1.0"?>
    <addressBook xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance"
                 xmlns="http://www.oreilly.com/catalog/javaxml"
                 xsi:schemaLocation="http://www.oreilly.com/catalog/javaxml
                                     mySchema.xsd">

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: XML Document Using XML Schema?{rep points included!}

    Pretty much.... in this case, one could have multiple addressBook schemas based on application.... Outlook, ThunderBird, Netscape, myOwn, etc....

    Each one would have it's own slightly different format.... but they are all addressBook. By putting a namespace on the schema, it differentiates between just which schema should be used.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: XML Document Using XML Schema?{rep points included!}

    Thanks TG. One more thing. If the line below specifies the namespace and schema to use then what is the second line ((located @ my previous post) the one that declares the schema instance) used for? The line below seems to cover the location and .xsd file to use.
    Code:
    xsi:schemaLocation="http://www.oreilly.com/catalog/javaxml
                                     mySchema.xsd">

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: XML Document Using XML Schema?{rep points included!}

    Quote Originally Posted by Dilenger4
    Im reading an old book (June 2000) on XML so i don't know if this is still the way to do things. The book shows the following lines. I understand that the first line is a PI instruction to the XML parser.
    Actually, no. Although the xml declaration has the same syntax as a generic processing instruction, according to the standard it isn't, and thus, for example, never shows up as a processing instruction node in the DOM tree, or is reported as a processing instruction event by SAX parsers.

    Now the second is the xml schema namespace.
    More precisely, it's the XML schema instance namespace that contains schemaLocation and a few other attributes. The schema namespace, on the other hand, contains the schema element, the element element, etc.

    Third is the xml doc namespace and the forth is the location of the xml schema doc .xsd.
    Correct.

    Now why is it needed that a namespace be defined for the schema?
    Not sure what you mean.
    The schema instance namespace is introduced because the schemaLocation element from there is used. The javaxml namespace is introduced to define a namespace for the document. The declaration could have been omitted; in that case, the element addressBook would have been in the default namespace. The namespace here is to differentiate the javaxml addressBook from the csharpxml addressBook and the pythonxml addressBook, etc.
    The schemaLocation ties namespaces and schema files together. This attribute declares that for all elements from the javaxml namespace, use mySchema.xsd as the schema.
    To tie a schema file to the default namespace, you'd use the noNamespaceSchemaLocation attribute.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: XML Document Using XML Schema?{rep points included!}

    Thanks CB. The following clears things up.
    Posted by CornedBee

    More precisely, it's the XML schema instance namespace that contains schemaLocation and a few other attributes.
    So the xml schema namespace has nothing to do with a user definable .xsd, meaning it dosen't specify the location and or the .xsd itself.

    I guess the xml schema namespace is almost like declaring a namespace in a jsp page so you can use the tags contained within.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: XML Document Using XML Schema?{rep points included!}

    Correct. In fact, it's exactly like that, except that one uses the xmlns:* pseudo-attributes, while the other uses custom JSP instructions or tags from the jsp namespace.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Resolved Re: XML Document Using XML Schema?{rep points included!}

    Fantasitc! Thanks guys. CB i haven't forgot about the reps. I still owe you from previous stuff.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width