Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > RelaxNG or W3C schema declaration for xml:space FIXED attribute

Reply
Thread Tools

RelaxNG or W3C schema declaration for xml:space FIXED attribute

 
 
Manuel Collado
Guest
Posts: n/a
 
      10-13-2011
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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      10-13-2011
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/
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      10-13-2011
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/
 
Reply With Quote
 
Manuel Collado
Guest
Posts: n/a
 
      10-13-2011
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

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      10-13-2011
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/
 
Reply With Quote
 
Manuel Collado
Guest
Posts: n/a
 
      10-13-2011
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

 
Reply With Quote
 
Manuel Collado
Guest
Posts: n/a
 
      10-20-2011
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML W3C Schema, check excistence of attribute depending on otherattributes RolfK XML 2 09-10-2008 02:22 PM
Castorizing W3C's Schema Schema virmundi@gmail.com Java 1 05-18-2006 05:28 AM
w3c Schema naming patterns and template-based schema generation Steve Jorgensen XML 0 08-09-2005 08:05 AM
Help with RelaxNG and Trang (and Emacs) David Abrahams XML 0 02-09-2005 04:07 PM
DTD to Schema (W3C): Is it possible to combine datatyping at element level and attribute value specifications??? Ingrid XML 0 08-03-2004 12:26 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57