Some very basic xml

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

    Some very basic xml

    Hello!

    I know this might not be the appropriate forum for xml question.
    But xml is so important for .NET I hope my basic question can be answered in
    this forum.

    I just wonder does every xml document have a XSD schema or XDR schema ?
    Is it possible to say that the purpose for schema is to have a definition
    for syntax.

    Or can anyone else give a basic explanation what schema is used for in .NET.

    //Tony


  • Pavel Minaev

    #2
    Re: Some very basic xml

    On Aug 12, 1:34 pm, "Tony Johansson" <johansson.ande rs...@telia.com >
    wrote:
    I just wonder does every xml document have a XSD schema or XDR schema ?
    No. Aside from the fact that there are many other ways to define an
    XML schema (e.g. old-fashioned DTDs, or RELAX NG), a document can have
    no schema at all.
    Is it possible to say that the purpose for schema is to have a definition
    for syntax.
    XML schema does not define the syntax - it defines the structure of
    the document, in terms of XML infoset. In case of W3C XML Schema
    (XSD), it can also augment the infoset of the document with things
    such as types, and default values for missing attributes and elements.
    Or can anyone else give a basic explanation what schema is used for in .NET.
    On the most basic level, to validate XML input and output against it.
    There's also the aforementioned XML infoset augmentation - for
    example, if you read an XML document with an associated schema into an
    instance of XmlDocument with validation enabled, and the schema
    defines some attributes with default values, those attributes will be
    present in XmlDocument even if they were absent in the original XML,
    and will have the default values as specified. In addition to that,
    every element is associated with the corresponding type in the XSD
    schema, and that type information can also be queried via .NET XML
    APIs, and used as needed (and, of course, xsi:type attribute can be
    used to explicitly specify types of elements in source XML).

    Comment

    • Tony Johansson

      #3
      Re: Some very basic xml

      Hello!

      One more question about xml.
      I read in a book about basic xml and it says.
      "An XML document could be a physical file on your computer or just a string
      in memory."

      The first part of the above sentence is normal that an xml document is a
      physical file on disk.
      But what does it mean when it says that it could be just a string in memory
      ?

      //Tony



      "Pavel Minaev" <int19h@gmail.c omskrev i meddelandet
      news:db0eae33-b082-40bc-bd87-80f3e9d7cbe7@2g 2000hsn.googleg roups.com...
      On Aug 12, 1:34 pm, "Tony Johansson" <johansson.ande rs...@telia.com >
      wrote:
      I just wonder does every xml document have a XSD schema or XDR schema ?
      No. Aside from the fact that there are many other ways to define an
      XML schema (e.g. old-fashioned DTDs, or RELAX NG), a document can have
      no schema at all.
      Is it possible to say that the purpose for schema is to have a definition
      for syntax.
      XML schema does not define the syntax - it defines the structure of
      the document, in terms of XML infoset. In case of W3C XML Schema
      (XSD), it can also augment the infoset of the document with things
      such as types, and default values for missing attributes and elements.
      Or can anyone else give a basic explanation what schema is used for in
      ..NET.

      On the most basic level, to validate XML input and output against it.
      There's also the aforementioned XML infoset augmentation - for
      example, if you read an XML document with an associated schema into an
      instance of XmlDocument with validation enabled, and the schema
      defines some attributes with default values, those attributes will be
      present in XmlDocument even if they were absent in the original XML,
      and will have the default values as specified. In addition to that,
      every element is associated with the corresponding type in the XSD
      schema, and that type information can also be queried via .NET XML
      APIs, and used as needed (and, of course, xsi:type attribute can be
      used to explicitly specify types of elements in source XML).


      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: Some very basic xml

        On Aug 12, 12:21 pm, "Tony Johansson" <johansson.ande rs...@telia.com >
        wrote:
        One more question about xml.
        I read in a book about basic xml and it says.
        "An XML document could be a physical file on your computer or just a string
        in memory."
        >
        The first part of the above sentence is normal that an xml document is a
        physical file on disk.
        But what does it mean when it says that it could be just a string in memory
        ?
        It means that:

        string xml = "<?xml version='1.0' encoding='UTF-8' ?><root><elemen t
        attr='value' /></root>";

        is a perfectly valid XML document. It's just data.

        Jon

        Comment

        • Pavel Minaev

          #5
          Re: Some very basic xml


          Tony Johansson wrote:
          Hello!
          >
          One more question about xml.
          I read in a book about basic xml and it says.
          "An XML document could be a physical file on your computer or just a string
          in memory."
          >
          The first part of the above sentence is normal that an xml document is a
          physical file on disk.
          But what does it mean when it says that it could be just a string in memory
          To quote the W3C XML spec (http://www.w3.org/TR/xml/#sec-documents):

          Definition: A data object is an XML document if it is well-formed,
          as defined in this specification.
          Definition: A textual object is a well-formed XML document if:

          1. Taken as a whole, it matches the production labeled document.
          2. It meets all the well-formedness constraints given in this
          specification.
          3. Each of the parsed entities which is referenced directly or
          indirectly within the document is well-formed.

          Note that this specifically refers to some abstract "textual objects",
          and not files. A "textual object" can be a string in memory, a field
          in the database (SQL Server has XML data type for fields, for
          example), an output of a program to stdout, an HTTP Web service
          responce, etc. So long as it has textual representation which matches
          the XML grammar, it is XML.

          Comment

          Working...