xml schema

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Johansson

    xml schema

    Hello!

    First of all does every Xml document have a schema ?

    I'm trying to get the right feeling for what a xml schema is ?
    As far as I understand it's used for defining a structure how you are permitted to right your Xml document.

    Is it possible to make a simile to C# in some sensible way.

    //Tony


  • Jon Skeet [C# MVP]

    #2
    Re: xml schema

    Tony Johansson <johansson.ande rsson@telia.com wrote:
    First of all does every Xml document have a schema ?
    No.
    I'm trying to get the right feeling for what a xml schema is ?
    As far as I understand it's used for defining a structure how you are
    permitted to right your Xml document.
    Yes, pretty much.
    Is it possible to make a simile to C# in some sensible way.
    I have no idea what you mean by this, I'm afraid.

    --
    Jon Skeet - <skeet@pobox.co m>
    Web site: http://www.pobox.com/~skeet
    Blog: http://www.msmvps.com/jon.skeet
    C# in Depth: http://csharpindepth.com

    Comment

    • Tony Johansson

      #3
      Re: xml schema

      Hello!

      When should a Xml schema be used and when can you skip it ?

      //Tony

      "Jon Skeet [C# MVP]" <skeet@pobox.co mskrev i meddelandet
      news:MPG.230e09 8880ff515aec8@m snews.microsoft .com...
      Tony Johansson <johansson.ande rsson@telia.com wrote:
      First of all does every Xml document have a schema ?
      >
      No.
      >
      I'm trying to get the right feeling for what a xml schema is ?
      As far as I understand it's used for defining a structure how you are
      permitted to right your Xml document.
      >
      Yes, pretty much.
      >
      Is it possible to make a simile to C# in some sensible way.
      >
      I have no idea what you mean by this, I'm afraid.
      >
      --
      Jon Skeet - <skeet@pobox.co m>
      Web site: http://www.pobox.com/~skeet
      Blog: http://www.msmvps.com/jon.skeet
      C# in Depth: http://csharpindepth.com

      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: xml schema

        Tony Johansson <johansson.ande rsson@telia.com wrote:
        When should a Xml schema be used and when can you skip it ?
        It's a bit like static typing vs dynamic typing - XML schema allows you
        to validate the XML document to some extent. It also enables editors to
        provide the equivalent of Intellisense.

        Personally I'm not a massive fan, but it depends on the situation. It's
        a good way of conveying a specification in a machine-readable format.

        --
        Jon Skeet - <skeet@pobox.co m>
        Web site: http://www.pobox.com/~skeet
        Blog: http://www.msmvps.com/jon.skeet
        C# in Depth: http://csharpindepth.com

        Comment

        • Ken Foskey

          #5
          Re: xml schema

          On Thu, 14 Aug 2008 11:46:33 +0200, Tony Johansson wrote:
          Hello!
          >
          When should a Xml schema be used and when can you skip it ?
          My take on this is that schema validation should be used sparingly in
          production. Strict adherence to an XML standard (schema) must be done
          during testing between exchanging parties but you should be free to
          handle schema validation errors in production.

          Ken

          Comment

          • Mike Schilling

            #6
            Re: xml schema


            "Tony Johansson" <johansson.ande rsson@telia.com wrote in message
            news:uAuyo4e$IH A.1296@TK2MSFTN GP02.phx.gbl...
            Hello!
            First of all does every Xml document have a schema ?
            I'm trying to get the right feeling for what a xml schema is ?
            As far as I understand it's used for defining a structure how you
            are permitted to right your Xml document.
            Is it possible to make a simile to C# in some sensible way.
            An XML document without a schema is roughly like a C# object whose
            only property is a list of name-value pairs. You can iterate through
            the list, but until you do, there's no way to tell what names will be
            present or what type each value will have.

            An XML document with a schema is like a normal C# object. The type of
            the object (just like the schema) shows you the properties and their
            types.


            Comment

            • Pavel Minaev

              #7
              Re: xml schema

              On Aug 14, 1:54 pm, Ken Foskey <rmove.fos...@o ptushome.com.au wrote:
              My take on this is that schema validation should be used sparingly in
              production.  Strict adherence to an XML standard (schema) must be done
              during testing between exchanging parties but you should be free to
              handle schema validation errors in production.
              A better rule is to be lax on your input but strict on your output. So
              you wouldn't validate XML when reading it, trying to detect and
              recover from errors as you go, but you'd validate your outputs, so as
              to be sure that it adhers to the spec, and your own program and any
              third-party product can read it back correctly.

              Also, .NET XML schema validation classes allow one to do incremental
              validation, and perform recoverable error handling.

              Comment

              • Jon Skeet [C# MVP]

                #8
                Re: xml schema

                Pavel Minaev <int19h@gmail.c omwrote:
                On Aug 14, 1:54 pm, Ken Foskey <rmove.fos...@o ptushome.com.au wrote:
                My take on this is that schema validation should be used sparingly in
                production.  Strict adherence to an XML standard (schema) must be done
                during testing between exchanging parties but you should be free to
                handle schema validation errors in production.
                A better rule is to be lax on your input but strict on your output.
                I find it's better to be strict on both input and output. Everyone
                being lax on input means that errors on output don't get noticed. Being
                lax on input is what got browsers into such a horrible mess as they
                tried to work out what invalid HTML was meant to read.

                Invalid XML is particularly inexcusable, as it's meant to be machine
                generated - if something is generating XML which doesn't conform to the
                spec, it is *broken* and you shouldn't work with it IMO.

                --
                Jon Skeet - <skeet@pobox.co m>
                Web site: http://www.pobox.com/~skeet
                Blog: http://www.msmvps.com/jon.skeet
                C# in Depth: http://csharpindepth.com

                Comment

                • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

                  #9
                  Re: xml schema

                  Tony Johansson wrote:
                  When should a Xml schema be used and when can you skip it ?
                  You should use it whenever you have time to do one.

                  Arne

                  Comment

                  • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

                    #10
                    Re: xml schema

                    Pavel Minaev wrote:
                    On Aug 14, 1:54 pm, Ken Foskey <rmove.fos...@o ptushome.com.au wrote:
                    >My take on this is that schema validation should be used sparingly in
                    >production. Strict adherence to an XML standard (schema) must be done
                    >during testing between exchanging parties but you should be free to
                    >handle schema validation errors in production.
                    >
                    A better rule is to be lax on your input but strict on your output. So
                    you wouldn't validate XML when reading it, trying to detect and
                    recover from errors as you go, but you'd validate your outputs, so as
                    to be sure that it adhers to the spec, and your own program and any
                    third-party product can read it back correctly.
                    >
                    Also, .NET XML schema validation classes allow one to do incremental
                    validation, and perform recoverable error handling.
                    I would not recommend continue processing XML that is not
                    valid according to the expected XSD.

                    Something is wrong and until the reason is invesigated
                    it could do more harm than good to continue.

                    Arne

                    Comment

                    Working...