xml SYSTEM vs PUBLIC

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

    #1

    xml SYSTEM vs PUBLIC

    Hi !





    In an XML DOCTYPE declaration you can use either PUBLIC or
    SYSTEM attributes:

    <!DOCTYPE RootElement SYSTEM "SomeDTD.dt d">
    <!DOCTYPE RootElement PUBLIC "SomeDTD.dt d">

    When should I use SYSTEM and when should I use PUBLIC ?




    Regards,
    Razvan
  • David Carlisle

    #2
    Re: xml SYSTEM vs PUBLIC

    mihai11@mailcit y.com (Razvan) writes:
    [color=blue]
    > Hi !
    >
    >
    >
    >
    >
    > In an XML DOCTYPE declaration you can use either PUBLIC or
    > SYSTEM attributes:
    >
    > <!DOCTYPE RootElement SYSTEM "SomeDTD.dt d">
    > <!DOCTYPE RootElement PUBLIC "SomeDTD.dt d">
    >
    > When should I use SYSTEM and when should I use PUBLIC ?
    >
    >
    >
    >
    > Regards,
    > Razvan[/color]


    No, you could do that in SGML but in XML you _Always_ have to have a
    SYSTEM identifier. If you use PUBLIC you gave to give _both_ a public ID
    and the SYSTEM.

    Although XML doesn't enforce this PUBLIC identifiers usually follow the
    Formal Public Identifier syntax which has a bunch of fields separated by
    / that encode the author and identity of the dtd file but not (usually0
    its location. eg MathML uses:

    <!DOCTYPE math
    PUBLIC "-//W3C//DTD MathML 2.0//EN"
    "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd"[color=blue]
    >[/color]

    The PUBLIC Identifier "-//W3C//DTD MathML 2.0//EN shows it's (not from
    ISO, the -) is from W3C is called DTD MathML 2.0 and uses English as
    its documentaion, (one possible) URI where you might actually find the
    thing is given by the SYSTEM ID
    "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd"

    David

    Comment

    • Razvan

      #3
      Re: xml SYSTEM vs PUBLIC

      Hi David,




      Thanks for your answer.


      No, you could do that in SGML but in XML you _Always_ have to have a
      SYSTEM identifier.


      If that is true then why have a PUBLIC identifier at all ? What is
      their purpose ?

      Is there some limitation to the type of data that you can put in
      SYSTEM vs. PUBLIC identifiers ? For example: SYSTEM only supports URLs
      (like http://www.w3c.org/ ) while PUBLIC only supports local paths ?
      (this is just an example)



      Regards,
      Razvan

      Comment

      • David Carlisle

        #4
        Re: xml SYSTEM vs PUBLIC



        If that is true then why have a PUBLIC identifier at all ? What is
        their purpose

        beware that you are skirting on the edge of a very deep "debate":-)
        Basically the public identifier gives a unique canonical name for the
        dtd that you can recognise; whereas the SYSTEM identifier may well point
        at a local path on the original author's system that doesn't make sense
        on yours. An XML parser may use either (or both) identifiers to find the
        file.

        So if you have an xml parser that has an xml catalogue of some sort that
        recognises say XHTML or Docbokk PUBLIC identifier, the file will work
        even if the system ID points at a file not accessable to you as your
        parser can use the catalogue to map the public ID to a local
        copy. Conversely if you don't have that public id in your catalogue (or
        if there is no public id) then you can perhaps find the file directly by
        using the system id.

        When the syntax was invented, for sgml, this last step would most
        likely fail as it would be a local file name so it would assume that you
        had local files in the same position. In XML when the SYSTEM is supposed
        to be a URI and so perhaps usable from anywhere in the world there is an
        argument (that I don't personally hold, but which is not unreasonable,
        and comes up often) that the SYSTEM ID is all you need and PUBLIC IDs no
        longer serve a purpose.

        David

        Comment

        • Razvan

          #5
          Re: xml SYSTEM vs PUBLIC

          Hi !



          Look what I've found on a web site:
          (http://www.adp-gmbh.ch/xml/dtd.html)


          SYSTEM
          <!DOCTYPE root-element SYSTEM "http://xyz.qq/abc/def.dtd">

          SYSTEM means that a validating parser needs the dtd when it validates
          an XML document.


          PUBLIC
          <!DOCTYPE root-element PUBLIC "path/abc/def.dtd">

          PUBLIC means that a validating parser might use a 'cached' ????
          version of the DTD.


          Mixing
          <!DOCTYPE root-element PUBLIC "path/abc/def.dtd"
          "http://xyz.qq/abc/def.dtd">

          This form uses http://xyz.qq.abc.def.dtd only if path/abc/def.dtd is
          not available.



          Regards,
          Razvan

          Comment

          • David Carlisle

            #6
            Re: xml SYSTEM vs PUBLIC

            [color=blue]
            > Look what I've found on a web site:[/color]

            Don't believe everything you read:-)

            if in doubt go back to teh definition:

            http://www.w3.org/TR/2004/REC-xml11-...#NT-ExternalID

            [75] ExternalID ::= 'SYSTEM' S SystemLiteral
            | 'PUBLIC' S PubidLiteral S SystemLiteral


            which says that an ExternalID is either SYSTEM followed by a literal or
            PUBLIC followed by two literals separated by white space. there is not
            an option of having PUBLIC followed by just one literal. (except for the
            declarations of notations which also include a special PUBLIC-only
            production 83).

            David

            Comment

            Working...