RelaxNG or W3C schema declaration for xml:space FIXED attribute

M

Manuel Collado

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.
 
M

Martin Honnen

Manuel said:
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?
 
M

Martin Honnen

Martin said:
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.
 
M

Manuel Collado

El 13/10/2011 18:39, Martin Honnen escribió:
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.
 
M

Martin Honnen

Manuel said:
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.
 
M

Manuel Collado

El 13/10/2011 19:37, Martin Honnen escribió:
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,
 
M

Manuel Collado

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ó:

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top