Problem with DTD declaration

Discussion in 'XML' started by Simon Brooke, Aug 7, 2008.

  1. Simon Brooke

    Simon Brooke Guest

    I have a DTD. If I declare it at the top of my XML file, as so:

    <!DOCTYPE application PUBLIC "-//CYGNETS//DTD ADL 0.1//EN"
    "http://libs.cygnets.co.uk/adl/unstable/ADL/schemas/adl-0.dtd">

    then editors such as emacs (PSGML), Oxygen and Microsoft Visual Studio
    parse the DTD and offer me context sensitive menus to insert the right
    elements and the right attributes in the right places. So the DTD
    really is there and really can be parsed. The top-level element in my
    document structure is the element 'application', which is declared as
    follows:

    <!--
    the application that the document describes: required top level
    element

    name: the name of this application
    version: the version number of this application
    revision: the revision of the ADL document
    xmlns: XML namespace, in case required
    -->
    <!ELEMENT application ( specification?, documentation?, content?,
    typedef*, group*, entity*)>
    <!ATTLIST application
    name CDATA #REQUIRED
    version CDATA #IMPLIED
    revision CDATA #IMPLIED
    xmlns CDATA #IMPLIED>

    So, everything's fine, you'd think. No problem.

    But when I try to transform my document using XSLT, I get:

    C:\Projects\ESA-McIntosh-CADLink\ESA-McIntosh-CADLink.build(74,4):
    Could not perform XSLT transformation of 'C:\Projects\ESA-McIntosh-
    CADLink\ESATool\ESA-McIntosh-CADLink.adl.xml' using stylesheet
    'file:///L:/adl/unstable/ADL//transforms/adl2canonical.xslt'.
    The 'application' element is not declared.

    If I remove - or comment out - the DTD declaration line the transform
    works perfectly.

    This is not a bug in some particular XSL engine, because MSXSL and
    Xalan behave identically (except for the exact text of the error
    message). So clearly I've got something wrong. But - what is it?
     
    Simon Brooke, Aug 7, 2008
    #1
    1. Advertising

  2. Martin Honnen, Aug 7, 2008
    #2
    1. Advertising

  3. Simon Brooke

    Simon Brooke Guest

    On Aug 7, 1:24 pm, Martin Honnen <> wrote:
    > Simon Brooke wrote:
    > > I have a DTD. If I declare it at the top of my XML file, as so:

    >
    > > <!DOCTYPE application PUBLIC "-//CYGNETS//DTD ADL 0.1//EN"
    > > "http://libs.cygnets.co.uk/adl/unstable/ADL/schemas/adl-0.dtd">

    >
    > When I try to loadhttp://libs.cygnets.co.uk/adl/unstable/ADL/schemas/adl-0.dtdwith
    > Firefox then all I get is a document saying "Virtual host not found on
    > this server".


    Yes, sorry - not visible outside the firewall (intentionally).
     
    Simon Brooke, Aug 7, 2008
    #3
  4. In article <489ae963$0$11740$-online.net>,
    Martin Honnen <> wrote:

    >> I have a DTD. If I declare it at the top of my XML file, as so:
    >>
    >> <!DOCTYPE application PUBLIC "-//CYGNETS//DTD ADL 0.1//EN"
    >> "http://libs.cygnets.co.uk/adl/unstable/ADL/schemas/adl-0.dtd">


    >When I try to load
    >http://libs.cygnets.co.uk/adl/unstable/ADL/schemas/adl-0.dtd with
    >Firefox then all I get is a document saying "Virtual host not found on
    >this server".


    Perhaps Simon is using a catalog to resolve the public ID?

    Simon: can you post a (small) complete XML document that exhibits
    the problem, and ensure that the DTD is at a working URL?

    -- Richard
    --
    Please remember to mention me / in tapes you leave behind.
     
    Richard Tobin, Aug 7, 2008
    #4
  5. Simon Brooke

    Simon Brooke Guest

    On Aug 7, 2:25 pm, (Richard Tobin) wrote:
    > In article <489ae963$0$11740$-online.net>,
    > Martin Honnen  <> wrote:
    >
    > >> I have a DTD. If I declare it at the top of my XML file, as so:

    >
    > >> <!DOCTYPE application PUBLIC "-//CYGNETS//DTD ADL 0.1//EN"
    > >> "http://libs.cygnets.co.uk/adl/unstable/ADL/schemas/adl-0.dtd">

    > >When I try to load
    > >http://libs.cygnets.co.uk/adl/unstable/ADL/schemas/adl-0.dtdwith
    > >Firefox then all I get is a document saying "Virtual host not found on
    > >this server".

    >
    > Perhaps Simon is using a catalog to resolve the public ID?
    >
    > Simon: can you post a (small) complete XML document that exhibits
    > the problem, and ensure that the DTD is at a working URL?


    Yes - that would obviously be sensible!

    <URL:http://www.jasmine.org.uk/~simon/tmp/testapp.adl.xml>

    It should be possible to transform it with this XSLT:

    <URL:http://www.jasmine.org.uk/~simon/tmp/adl2canonical.xslt>
     
    Simon Brooke, Aug 7, 2008
    #5
  6. In article <>,
    Simon Brooke <> wrote:

    ><URL:http://www.jasmine.org.uk/~simon/tmp/testapp.adl.xml>
    >
    >It should be possible to transform it with this XSLT:
    >
    ><URL:http://www.jasmine.org.uk/~simon/tmp/adl2canonical.xslt>


    No problem with the file when running lxt or saxon, but your XSLT has
    at least one error: the template for adl:application outputs a
    comment, then calls <xsl:apply-templates select="@* | node()"/> which
    results in attributes being copied too late.

    -- Richard
    --
    Please remember to mention me / in tapes you leave behind.
     
    Richard Tobin, Aug 7, 2008
    #6
  7. Simon Brooke wrote:

    > <URL:http://www.jasmine.org.uk/~simon/tmp/testapp.adl.xml>
    >
    > It should be possible to transform it with this XSLT:
    >
    > <URL:http://www.jasmine.org.uk/~simon/tmp/adl2canonical.xslt>


    Which version of MSXML are you using?
    Transformation seems to work fine when using MSXML 3, 4 or 5, only MSXML
    6 when you try to validate the XML input document against the DTD
    complains: "The element 'application' is used but not declared in the
    DTD/Schema.". I am currently not sure why that happens but if you don't
    need validation and simply want to load the XML to transform it you can
    always switch validation off by setting
    document.validateOnParse = false
    on the MSXML2.DOMDocument.6.0 you use to load the XML input.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Aug 7, 2008
    #7
  8. Simon Brooke wrote:

    > <URL:http://www.jasmine.org.uk/~simon/tmp/testapp.adl.xml>
    >
    > It should be possible to transform it with this XSLT:
    >
    > <URL:http://www.jasmine.org.uk/~simon/tmp/adl2canonical.xslt>


    I have no problems applying the stylesheet with Xalan Java. Saxon 6.5.5
    complains about the problem already raised:

    "Error at xsl:copy on line 348 of
    http://www.jasmine.org.uk/~simon/tmp/adl2canonical.xslt:
    Cannot write an attribute when there is no open start tag
    Transformation failed: Run-time errors were reported"

    Both Xalan and Saxon were run with Sun Java 1.5.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Aug 7, 2008
    #8
  9. In article <489b03c8$0$11736$-online.net>,
    Martin Honnen <> wrote:

    >Which version of MSXML are you using?


    Didn't there use to be a problem with Microsoft's parser requiring
    xmlns attribute declarations to be #FIXED when validating? Or
    something like that...

    -- Richard
    --
    Please remember to mention me / in tapes you leave behind.
     
    Richard Tobin, Aug 7, 2008
    #9
    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. Joseph Tilian
    Replies:
    0
    Views:
    377
    Joseph Tilian
    Dec 21, 2004
  2. Ronald Fischer
    Replies:
    4
    Views:
    1,806
    Ronald Fischer
    Mar 17, 2005
  3. Simon Brooke
    Replies:
    5
    Views:
    773
    Simon Brooke
    Jul 25, 2003
  4. Sarah Haskins
    Replies:
    3
    Views:
    1,472
    Puff Addison
    Jan 15, 2004
  5. test
    Replies:
    2
    Views:
    2,175
    Oliver Wong
    Jul 28, 2006
Loading...

Share This Page