New to xml schema - does the dtd/schema validation happens always ?

Discussion in 'XML' started by pramodr, Apr 1, 2009.

  1. pramodr

    pramodr Guest

    Hi group,

    I am a novice in XML technologies even though I have been exposed to
    it for quite some time. My question is as follows

    If a dtd or schema is supplied with the xml, is the xml validated
    always against the dtd/schema ?

    We specify the dtd (or schema) with a URL like the one below which is
    a part of a web deployment descriptor - web.xml. If the validation is
    mandatory why does'nt it throw me an error when I am working
    standalone (disconnected from the web) ?


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
    Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app id="WebApp_ID">

    </web-app>


    Thanks and regards
    Pramod R
     
    pramodr, Apr 1, 2009
    #1
    1. Advertising

  2. Re: New to xml schema - does the dtd/schema validation happens always?

    pramodr wrote:

    > I am a novice in XML technologies even though I have been exposed to
    > it for quite some time. My question is as follows
    >
    > If a dtd or schema is supplied with the xml, is the xml validated
    > always against the dtd/schema ?


    No, you need a validating parser (and in the case of schemas you even
    need one that supports schemas) and you usually need to enable
    validation. It all depends on the API of the parser you use respectively
    on the configuration of the XML editor you might use.





    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Apr 1, 2009
    #2
    1. Advertising

  3. Re: New to xml schema - does the dtd/schema validation happens always?

    pramodr a écrit :
    > Hi group,
    >
    > I am a novice in XML technologies even though I have been exposed to
    > it for quite some time. My question is as follows
    >
    > If a dtd or schema is supplied with the xml, is the xml validated
    > always against the dtd/schema ?


    The validation will be performed if you ask for it. It may depend on the
    parser used and on the application.

    >
    > We specify the dtd (or schema) with a URL like the one below which is
    > a part of a web deployment descriptor - web.xml. If the validation is
    > mandatory why does'nt it throw me an error when I am working
    > standalone (disconnected from the web) ?


    Some applications rely on a component called a catalog that maps URIs to
    resources stored in your local file system; this allow to avoid network
    connexion and work in a disconnected mode as you mentionned.

    In the case of servlet engines, their catalog just have to resolve very
    few and well-known URIs, and they are likely hard-coded and resolved to
    internal resources (in the jar).

    >
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
    > Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    > <web-app id="WebApp_ID">
    >
    > </web-app>
    >
    >
    > Thanks and regards
    > Pramod R



    --
    Cordialement,

    ///
    (. .)
    --------ooO--(_)--Ooo--------
    | Philippe Poulard |
    -----------------------------
    http://reflex.gforge.inria.fr/
    Have the RefleX !
     
    Philippe Poulard, Apr 1, 2009
    #3
  4. pramodr

    Peter Flynn Guest

    Re: New to xml schema - does the dtd/schema validation happens always?

    pramodr wrote:
    > Hi group,
    >
    > I am a novice in XML technologies even though I have been exposed to
    > it for quite some time. My question is as follows
    >
    > If a dtd or schema is supplied with the xml, is the xml validated
    > always against the dtd/schema ?


    It depends on what you open the document with (editor, processor, inline
    parser, custom app, etc). If the software is capable of validation, and
    if it's set to perform validation on opening the document, then it will
    do so. If it's not, it won't. Some editors, for example, only parse
    documents for well-formedness when you open them, and leave full
    validation to the user clicking on a button or saving the document after
    changes.

    > We specify the dtd (or schema) with a URL like the one below which is
    > a part of a web deployment descriptor - web.xml. If the validation is
    > mandatory why does'nt it throw me an error when I am working
    > standalone (disconnected from the web) ?


    Because the DOCTYPE Declaration refers to a URI as the SI for the DTD
    and it can't get it when you're disconnected from the net; and you don't
    have a local copy stored in a Catalog where it can be resolved against
    the FPI. You either need to be online, or you need to enable catalog
    resolution in your software.

    A URI as the SI is mandatory in XML if you work with a DTD; the FPI is
    optional. This was a hotly-debated topic at design time, and in
    retrospect it was a suboptimal decision: a mandatory FPI with a
    synchronised catalog and cache would have been much better. It was
    claimed at the time that this would have meant more work for software
    authors, which would have slowed implementation (in fact it can be
    implemented in a screenful of code or less); and that everyone would
    soon have permanent connections and limitless bandwidth (yeah, right).

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/

    > <?xml version="1.0" encoding="UTF-8"?>
    > <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
    > Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    > <web-app id="WebApp_ID">
    >
    > </web-app>
    >
    >
    > Thanks and regards
    > Pramod R
     
    Peter Flynn, Apr 5, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,659
    Markus
    Nov 23, 2005
  2. Replies:
    1
    Views:
    465
    Dave Mandelin
    Mar 21, 2006
  3. Michael TEpperis
    Replies:
    1
    Views:
    431
  4. NM
    Replies:
    6
    Views:
    502
    Default User
    Sep 20, 2006
  5. Replies:
    10
    Views:
    1,088
    Peter Flynn
    Sep 14, 2007
Loading...

Share This Page