Simple XML & XSD Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Jerde

    Simple XML & XSD Question

    We have developed about 80 XML documents, each probably 150 lines long, that
    are all supposed to conform to a schema. My understanding is the way to
    show that an XML document conforms to a schema is to include a reference to
    the XSD in the XML document, and check that it is valid.

    Some other members of the project team don't want to include a reference to
    the XSD in the XML documents, citing possible differences in parsers.

    Is my understanding of XML / XSD correct? That is, the standard way to
    prove that a well formed XML document conforms to a schema is to include the
    reference to the XSD in the XML document.

    Thanks.

    -- Mark


  • Patrick Philippot

    #2
    Re: Simple XML & XSD Question

    Mark Jerde wrote:[color=blue]
    > We have developed about 80 XML documents, each probably 150 lines
    > long, that are all supposed to conform to a schema. My understanding
    > is the way to show that an XML document conforms to a schema is to
    > include a reference to the XSD in the XML document, and check that it
    > is valid.
    >
    > Some other members of the project team don't want to include a
    > reference to the XSD in the XML documents, citing possible
    > differences in parsers.
    >
    > Is my understanding of XML / XSD correct? That is, the standard way
    > to prove that a well formed XML document conforms to a schema is to
    > include the reference to the XSD in the XML document.[/color]

    Hi Mark,

    A few remarks...

    1. One thing is for sure, there will be no way for a client application
    to validate the XML document against its schema if the document doesn't
    contain any reference to the schema and if the application is not made
    aware of this schema from an external source of information.

    2. Validating XML documents against their schema is not always necessary
    as long as they were produced in a safe way (e.g. they can be validated
    just after being produced). It depends on what you need to do with them
    and on how you distribute them.

    3.> the standard way to prove[color=blue]
    > that a well formed XML document
    > conforms to a schema is to
    > include the reference to the XSD in the XML document[/color]

    Adding a reference to the schema in the document will not prove
    anything. It depends on how the client application loads the XML
    document. For example, in .Net, if you don't use a validating reader, no
    validation occurs. The schema reference is just ignored. Again, you can
    provide the schema's URL to the client application, if needed, by using
    an external channel. In .Net, when using an XmlValidatingRe ader, the
    schema can be specified separately from the document itself (See Schemas
    property).

    4. >possible differences in parsers.

    If the schema is correctly defined, any reliable and correctly written
    validating parser will validate the document against that schema.
    There's no room for interpretation, the XSD specification is accurate
    enough, IMHO. If the parser fails to validate a valid document, then the
    parser is buggy. Not referencing the schema is not a protection against
    a buggy parser.

    --
    Patrick Philippot - Microsoft MVP
    MainSoft Consulting Services



    Comment

    • Cindy M  -WordMVP-

      #3
      Re: Simple XML & XSD Question

      Hi Mark,

      If you'd be using these in Microsoft Word, by using the same TargetNamespace
      in both the xml and xsd files you can get Word to associate the schema.
      Assuming it's been added to the user's schema library, that is.
      [color=blue]
      > We have developed about 80 XML documents, each probably 150 lines long, that
      > are all supposed to conform to a schema. My understanding is the way to
      > show that an XML document conforms to a schema is to include a reference to
      > the XSD in the XML document, and check that it is valid.
      >
      > Some other members of the project team don't want to include a reference to
      > the XSD in the XML documents, citing possible differences in parsers.
      >
      > Is my understanding of XML / XSD correct? That is, the standard way to
      > prove that a well formed XML document conforms to a schema is to include the
      > reference to the XSD in the XML document.
      >[/color]

      Cindy Meister
      INTER-Solutions, Switzerland



      This reply is posted in the Newsgroup; please post any follow question or
      reply in the newsgroup and not by e-mail :-)

      Comment

      • Mark Jerde

        #4
        Re: Simple XML & XSD Question

        Thanks, Patrick & Cindy.

        -- Mark


        Comment

        • Ruslan Popov

          #5
          Re: Simple XML & XSD Question

          I wonder is there a way to embed a schema into the document, rather then
          just referencing it. So that when the schema is needed it could be obtained
          directly from the document.

          --
          Yours, respectfully
          Ruslan Popov


          Comment

          • Patrick Philippot

            #6
            Re: Simple XML & XSD Question

            Ruslan Popov wrote:[color=blue]
            > I wonder is there a way to embed a schema into the document, rather
            > then just referencing it. So that when the schema is needed it could
            > be obtained directly from the document.[/color]

            Hi,

            For sure, you can do that. See an example of inline schemas here:




            However, using inline schemas generates new validation problems. For
            example, since the <schema> element is a child of the root element, the
            root element itself cannot be validated (when using an
            XmlValidatingRe ader for example).



            --
            Patrick Philippot - Microsoft MVP
            MainSoft Consulting Services



            Comment

            • XMLStick

              #7
              re:Simple XML &amp; XSD Question

              Use FREEWARE XMLFox XML/XSD editor:


              XMLFox is an XML editing and validation tool for creating valid,
              well-formed XML documents and/or XSD Schema. It includes an XML View,
              XML Tree, XML Grid, and XML Script modes for editing, as well as
              extensive find capabilities for text and XML data. Additional
              features include XML and Schema Validation, standard editing
              features, XSD Schema building and more.


              Posted Via Usenet.com Premium Usenet Newsgroup Services
              ----------------------------------------------------------
              ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
              ----------------------------------------------------------
              Best Usenet Service Providers 2025 ranked by Newsgroup Access Newsservers, Usenet Search, Features & Free Trial. Add VPN for privacy.

              Comment

              Working...