RelaxNG or W3C schema declaration for xml:space FIXED attribute

Discussion in 'XML' started by Manuel Collado, Oct 13, 2011.

  1. DTDs allow to declare:

    <!ATTLIST xxx xml:space ( preserve ) #FIXED 'preserve'>

    Is there a way to specify something like that in a RNG or XSD schema?
    The naive XSD declaration:

    <xs:attribute name="xml:space" default="preserve"/>

    is not accepted by tools because "xml:space" is not a valid attribute name.

    TIA.
    --
    Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
     
    Manuel Collado, Oct 13, 2011
    #1
    1. Advertising

  2. Manuel Collado wrote:
    > DTDs allow to declare:
    >
    > <!ATTLIST xxx xml:space ( preserve ) #FIXED 'preserve'>
    >
    > Is there a way to specify something like that in a RNG or XSD schema?
    > The naive XSD declaration:
    >
    > <xs:attribute name="xml:space" default="preserve"/>
    >
    > is not accepted by tools because "xml:space" is not a valid attribute name.


    Have you tried
    <xs:attribute ref="xml:space" default="preserve"/>
    probably needing an
    <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
    in your schema?


    --

    Martin Honnen --- MVP Data Platform Development
    http://msmvps.com/blogs/martin_honnen/
     
    Martin Honnen, Oct 13, 2011
    #2
    1. Advertising

  3. Martin Honnen wrote:
    > Manuel Collado wrote:
    >> DTDs allow to declare:
    >>
    >> <!ATTLIST xxx xml:space ( preserve ) #FIXED 'preserve'>
    >>
    >> Is there a way to specify something like that in a RNG or XSD schema?
    >> The naive XSD declaration:
    >>
    >> <xs:attribute name="xml:space" default="preserve"/>
    >>
    >> is not accepted by tools because "xml:space" is not a valid attribute
    >> name.

    >
    > Have you tried
    > <xs:attribute ref="xml:space" default="preserve"/>
    > probably needing an
    > <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
    > in your schema?


    If your XML parser does not have a schema built in for the namespace you
    need
    <xs:import namespace="http://www.w3.org/XML/1998/namespace"
    schemaLocation="http://www.w3.org/2001/xml.xsd"/>
    but then the xs:attribute ref="xml:space" should work. At least for me
    here a simple example with jEdit and Xerces works.



    --

    Martin Honnen --- MVP Data Platform Development
    http://msmvps.com/blogs/martin_honnen/
     
    Martin Honnen, Oct 13, 2011
    #3
  4. El 13/10/2011 18:39, Martin Honnen escribió:
    > Manuel Collado wrote:
    >> DTDs allow to declare:
    >>
    >> <!ATTLIST xxx xml:space ( preserve ) #FIXED 'preserve'>
    >>
    >> Is there a way to specify something like that in a RNG or XSD schema?
    >> The naive XSD declaration:
    >>
    >> <xs:attribute name="xml:space" default="preserve"/>
    >>
    >> is not accepted by tools because "xml:space" is not a valid attribute
    >> name.

    >
    > Have you tried
    > <xs:attribute ref="xml:space" default="preserve"/>


    Not yet, doing it just now

    > probably needing an
    > <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
    > in your schema?


    Already imported.

    Thanks for the hint!

    Well, 'ref="xml:space"' is accepted, but for some reason the XML
    processing tool (a validating editor) doesn't preserve whitespace of the
    affected element if the xml:space attribute is omitted.

    The aforementioned DTD declaration (#FIXED) forces compliant processing
    tools to behave as if the xml:space attribute was present, event if
    actually omitted.

    Any thought?

    Thanks again.
    --
    Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
     
    Manuel Collado, Oct 13, 2011
    #4
  5. Manuel Collado wrote:

    > Well, 'ref="xml:space"' is accepted, but for some reason the XML
    > processing tool (a validating editor) doesn't preserve whitespace of the
    > affected element if the xml:space attribute is omitted.
    >
    > The aforementioned DTD declaration (#FIXED) forces compliant processing
    > tools to behave as if the xml:space attribute was present, event if
    > actually omitted.
    >
    > Any thought?


    Does that editor do schema based validation? I think as far as I
    understand the W3C schema language you should have the right definition.
    If you tell us which editor you use then maybe other users reading here
    can help. Or ask on a mailing list or forum dedicated to that editor.


    --

    Martin Honnen --- MVP Data Platform Development
    http://msmvps.com/blogs/martin_honnen/
     
    Martin Honnen, Oct 13, 2011
    #5
  6. El 13/10/2011 19:37, Martin Honnen escribió:
    > Manuel Collado wrote:
    >
    >> Well, 'ref="xml:space"' is accepted, but for some reason the XML
    >> processing tool (a validating editor) doesn't preserve whitespace of the
    >> affected element if the xml:space attribute is omitted.
    >>
    >> The aforementioned DTD declaration (#FIXED) forces compliant processing
    >> tools to behave as if the xml:space attribute was present, even if
    >> actually omitted.
    >>
    >> Any thought?

    >
    > Does that editor do schema based validation? I think as far as I
    > understand the W3C schema language you should have the right definition.
    > If you tell us which editor you use then maybe other users reading here
    > can help. Or ask on a mailing list or forum dedicated to that editor.


    Than you, very much, for your help.

    The editor is XXE from XmlMind. Of course, it validates based on schemas
    (or DTDs, or RNGs, which are converted to schemas on the fly). I believe
    it uses Xerxes to parse documents (and their schemas) when loaded.

    The schema I'm trying to hack is
    http://www.w3.org/2007/schema-for-xslt20.xsd

    The goal is to visually edit a restricted form of XSLT code in which
    literal result text fragments are only allowed inside <xsl:text>
    elements. This restriction should permit XSLT code re-indentation
    without changing its meaning at all.

    The weird thing is that XXE recognizes the schema as expected, but
    doesn't associate <xsl:text> elements with their specification (as it
    does with other <xsl:..> elements). This occurs just with the original
    (unmodified) schema-for-xslt20.xsd

    There must be a subtle problem somewhere. The XXE forum is certainly the
    next place to ask.

    Regards,
    --
    Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
     
    Manuel Collado, Oct 13, 2011
    #6
  7. Sorry, this is a long post. Thanks you for your patience.

    El 14/10/2011 0:54, Manuel Collado escribió:
    > El 13/10/2011 19:37, Martin Honnen escribió:
    >> Manuel Collado wrote:
    >>
    >>> Well, 'ref="xml:space"' is accepted, but for some reason the XML
    >>> processing tool (a validating editor) doesn't preserve whitespace of the
    >>> affected element if the xml:space attribute is omitted.
    >>>
    >>> The aforementioned DTD declaration (#FIXED) forces compliant processing
    >>> tools to behave as if the xml:space attribute was present, even if
    >>> actually omitted.
    >>>
    >>> Any thought?

    >>
    >> Does that editor do schema based validation? I think as far as I
    >> understand the W3C schema language you should have the right definition.
    >> If you tell us which editor you use then maybe other users reading here
    >> can help. Or ask on a mailing list or forum dedicated to that editor.

    >
    > Than you, very much, for your help.
    >
    > The editor is XXE from XmlMind. Of course, it validates based on schemas
    > (or DTDs, or RNGs, which are converted to schemas on the fly). I believe
    > it uses Xerxes to parse documents (and their schemas) when loaded.
    >
    > The schema I'm trying to hack is
    > http://www.w3.org/2007/schema-for-xslt20.xsd
    >
    > The goal is to visually edit a restricted form of XSLT code in which
    > literal result text fragments are only allowed inside <xsl:text>
    > elements. This restriction should permit XSLT code re-indentation
    > without changing its meaning at all.
    >
    > The weird thing is that XXE recognizes the schema as expected, but
    > doesn't associate <xsl:text> elements with their specification (as it
    > does with other <xsl:..> elements). This occurs just with the original
    > (unmodified) schema-for-xslt20.xsd
    >
    > There must be a subtle problem somewhere. The XXE forum is certainly the
    > next place to ask.


    After further attempts (without asking at the XXE forum) it seems that
    the problem relies in the schema-for-xslt20.xsd schema. XSLT elements
    inside literal result elements are not associated with their
    attribute/content schema. It seems that there is no bug in the XXE
    editor. This editor behaves correctly when given other (relaxng) schemas
    for XSLT documents.

    So my next question is:

    Is there a way to specify something like
    <!ATTLIST xxx xml:space ( preserve ) #FIXED 'preserve'>
    in a RNG schema?

    IIUC, the non-optional declaration:

    (1) <attribute name="space" ns="http://www.w3.org/XML/1998/namespace">
    <value type="string">preserve</value>
    </attribute>

    should do the trick.

    I'm working on in a well-known relaxng schema for XSLT:

    (http://www.thaiopensource.com/relaxng/xslt.rng)

    When (1) above is inserted for a specific XSLT element (xsl:text), it
    conflicts with a global declaration shared by a wide set of XSLT and
    literal elements

    (2) <zeroOrMore>
    <attribute>
    <anyName>
    <except>
    <nsName/>
    <nsName ns=""/>
    </except>
    </anyName>
    </attribute>
    </zeroOrMore>

    and gives an error:

    Document Type Error: duplicate attribute "space" from
    namespace "http://www.w3.org/XML/1998/namespace"

    Well,
    - Are there other publicly available RNG schemas for XSLT?
    - Is it possible to restrict (2) above to allow xml:* standard
    attributes except xml:space in particular?

    Thanks in advance.
    --
    Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
     
    Manuel Collado, Oct 20, 2011
    #7
    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. Ingrid
    Replies:
    0
    Views:
    414
    Ingrid
    Aug 3, 2004
  2. David Abrahams

    Help with RelaxNG and Trang (and Emacs)

    David Abrahams, Feb 9, 2005, in forum: XML
    Replies:
    0
    Views:
    594
    David Abrahams
    Feb 9, 2005
  3. Steve Jorgensen
    Replies:
    0
    Views:
    562
    Steve Jorgensen
    Aug 9, 2005
  4. Replies:
    1
    Views:
    374
  5. RolfK
    Replies:
    2
    Views:
    476
Loading...

Share This Page