Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

rng-users · RELAX NG users

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 194
  • Category: XML
  • Founded: Jun 18, 2005
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

Advanced
Messages Help
Messages 1299 - 1328 of 1479   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#1299 From: Casey Jordan <casey.jordan@...>
Date: Tue Jan 11, 2011 8:35 pm
Subject: DTD Conversion using trang.
caseydawsonj...
Send Email Send Email
 
Hi Group,

I am not sure if this is the right place to post this, but on the trang page it suggested here.

I am using trang via oxygen to convert DTD's to XSD, and am running into a strange problem. All my schema's have an import which is invalid and relates to the xsi namespace like so:

<xs:import namespace="##xsi" schemaLocation="xsi.xsd"/>

and it appears that there are alot of problems related to this throughout the converted schemas.

I do not fully understand what is going on here but I am hoping someone can shed some light on this or point me in the right direction.

Thanks,

Casey

--
--
Casey Jordan
Jorsek Software LLC.
"CaseyDJordan" on LinkedIn, Twitter & Facebook
Cell (585) 348 7399
Office (585) 239 6060
Jorsek.com


This message is intended only for the use of the Addressee(s) and may
contain information that is privileged, confidential, and/or exempt from
disclosure under applicable law.  If you are not the intended recipient,
please be advised that any disclosure  copying, distribution, or use of
the information contained herein is prohibited.  If you have received
this communication in error, please destroy all copies of the message,
whether in electronic or hard copy format, as well as attachments, and
immediately contact the sender by replying to this e-mail or by phone.
Thank you.

#1300 From: John Cowan <cowan@...>
Date: Tue Jan 11, 2011 11:37 pm
Subject: Re: DTD Conversion using trang.
johnwcowan
Send Email Send Email
 
Casey Jordan scripsit:

> I am using trang via oxygen to convert DTD's to XSD, and am running into a
> strange problem. All my schema's have an import which is invalid and relates
> to the xsi namespace like so:
>
> <xs:import namespace="##xsi" schemaLocation="xsi.xsd"/>

Trang doesn't know that xsi: is magic to XSD, and that it shouldn't
generate an XSD schema for it.  Just excise all references to importing
xsi from the generated schemas.

--
John Cowan          http://www.ccil.org/~cowan         cowan@...
The native charset of SMS messages supports English, French, mainland
Scandinavian languages, German, Italian, Spanish with no accents, and
GREEK SHOUTING.  Everything else has to be Unicode, which means you get
nly 70 16-bit characters in a text instead of 160 7-bit characters.

#1301 From: James Clark <jjc@...>
Date: Wed Jan 12, 2011 4:23 am
Subject: Re: DTD Conversion using trang.
james_j_clark
Send Email Send Email
 
I think this is a bug in trang.  The XSD output module should do something sensible with xsi:* attributes (probably just strip them out of the generated schema).

James

On Wed, Jan 12, 2011 at 6:37 AM, John Cowan <cowan@...> wrote:
 

Casey Jordan scripsit:



> I am using trang via oxygen to convert DTD's to XSD, and am running into a
> strange problem. All my schema's have an import which is invalid and relates
> to the xsi namespace like so:
>
> <xs:import namespace="##xsi" schemaLocation="xsi.xsd"/>

Trang doesn't know that xsi: is magic to XSD, and that it shouldn't
generate an XSD schema for it. Just excise all references to importing
xsi from the generated schemas.

--
John Cowan http://www.ccil.org/~cowan cowan@...
The native charset of SMS messages supports English, French, mainland
Scandinavian languages, German, Italian, Spanish with no accents, and
GREEK SHOUTING. Everything else has to be Unicode, which means you get
nly 70 16-bit characters in a text instead of 160 7-bit characters.



#1302 From: George Cristian Bina <george@...>
Date: Mon Jan 17, 2011 3:23 pm
Subject: [ann] oXygen XML Editor 12.1
george_bina
Send Email Send Email
 
Hi,

I am glad to announce that a new version of oXygen XML Editor is
available from our website
http://www.oxygenxml.com

oXygen version 12.1 improves the Relax NG support by adding highlights
for the Relax NG patterns. All the occurrences of a Relax NG pattern are
highlighted in the text when the caret is placed inside the pattern
name. In the right side of the editor there is an occurrences bar that
displays a summary of the pattern references from the Relax NG schema.
The pattern declaration is rendered with a darker color to be easier to
spot.

For the complete list of new additions and details please see
http://www.oxygenxml.com/index.html#new-version

Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

#1303 From: Dave Pawson <dave.pawson@...>
Date: Thu Jan 20, 2011 3:01 pm
Subject: repeated pattern
dpawson2000
Send Email Send Email
 
I have a pattern
length = xsd:token {pattern="[0-9]{1,3}pt|em|in|mm|cm)\s+"}

I want to specify an attribute that can have a value "3pt 36mm" or just 3pt,
i.e. the second length is optional?

How do I specify this please?

Trying
  |
(length, length?)

I get  error: group of "string" or "data" element  error?

TIA


--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

#1304 From: "G. Ken Holman" <gkholman@...>
Date: Thu Jan 20, 2011 3:17 pm
Subject: Re: repeated pattern
g_ken_holman
Send Email Send Email
 
At 2011-01-20 15:01 +0000, you wrote:
>I have a pattern
>length = xsd:token {pattern="[0-9]{1,3}pt|em|in|mm|cm)\s+"}
>
>I want to specify an attribute that can have a value "3pt 36mm" or just 3pt,

The above pattern does not appear to allow "3pt" because of the
mandatory trailing space.

>i.e. the second length is optional?
>
>How do I specify this please?
>
>Trying
>  |
>(length, length?)
>
>I get  error: group of "string" or "data" element  error?

Right ... I think you have to build it into your pattern.  Perhaps
something like this (untested) pattern to allow any number of lengths:

    pattern="\s*[0-9]{1,3}pt|em|in|mm|cm)(\s+[0-9]{1,3}pt|em|in|mm|cm))*\s*"

If you only one or two lengths then use "?" instead of "*" at the end
of the second length in the pattern.

I hope this helps.

. . . . . . . . . . . . . Ken


--
Contact us for world-wide XML consulting & instructor-led training
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/r/
G. Ken Holman                 mailto:gkholman@...
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

#1305 From: Bjoern Hoehrmann <derhoermi@...>
Date: Thu Jan 20, 2011 3:21 pm
Subject: Re: repeated pattern
hoermi
Send Email Send Email
 
* Dave Pawson wrote:
>I have a pattern
>length = xsd:token {pattern="[0-9]{1,3}pt|em|in|mm|cm)\s+"}
>
>I want to specify an attribute that can have a value "3pt 36mm" or just 3pt,
>i.e. the second length is optional?
>
>How do I specify this please?
>
>Trying
> |
>(length, length?)
>
>I get  error: group of "string" or "data" element  error?

What you are trying would seem to be disallowed, see section 7.2 in the
specification <http://relaxng.org/spec-20011203.html>, and would not
work anyway since you need some higher level logic to handle the white
space; in your regular expression you require white space at the end,
but you also want to match at the end of the string, which as I recall
the XML Schema regular expression language does not permit, so, you've
got to specify the repetition in the regular expression (by duplicating
the prefix most likely).
--
Björn Höhrmann · mailto:bjoern@... · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/

#1306 From: Dave Pawson <dave.pawson@...>
Date: Thu Jan 20, 2011 3:26 pm
Subject: Re: repeated pattern
dpawson2000
Send Email Send Email
 
Sorry Ken :-)

On 20 January 2011 15:21, Bjoern Hoehrmann <derhoermi@...> wrote:

> What you are trying would seem to be disallowed, see section 7.2 in the
> specification <http://relaxng.org/spec-20011203.html>, and would not
> work anyway since you need some higher level logic to handle the white
> space; in your regular expression you require white space at the end,
> but you also want to match at the end of the string, which as I recall
> the XML Schema regular expression language does not permit, so, you've
> got to specify the repetition in the regular expression (by duplicating
> the prefix most likely).

<el att="2pt 25mm"/>
would that be possible with a higher level pattern usage?
given
length = xsd:token {pattern="[0-9]{1,3}(pt|em|in|mm|cm)"}


Or is this the same restriction?

regards


--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

#1307 From: Dave Pawson <dave.pawson@...>
Date: Thu Jan 20, 2011 3:23 pm
Subject: Re: repeated pattern
dpawson2000
Send Email Send Email
 
On 20 January 2011 15:17, G. Ken Holman <gkholman@...> wrote:
> At 2011-01-20 15:01 +0000, you wrote:
>>I have a pattern
>>length = xsd:token {pattern="[0-9]{1,3}pt|em|in|mm|cm)\s+"}

>>How do I specify this please?
>>
>>Trying
>>  |
>>(length, length?)
>>
>>I get  error: group of "string" or "data" element  error?
>
> Right ... I think you have to build it into your pattern.  Perhaps
> something like this (untested) pattern to allow any number of lengths:
>
>   pattern="\s*[0-9]{1,3}pt|em|in|mm|cm)(\s+[0-9]{1,3}pt|em|in|mm|cm))*\s*"
>
> If you only one or two lengths then use "?" instead of "*" at the end
> of the second length in the pattern.



So I can't call up a named pattern this way?
Previously defined as
length = xsd:token {pattern="[0-9]{1,3}\s*(pt|em|in|mm|cm)\s+"}

I thought patterns allowed this indirection Ken?

regards

--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

#1308 From: John Cowan <cowan@...>
Date: Thu Jan 20, 2011 3:35 pm
Subject: Re: repeated pattern
johnwcowan
Send Email Send Email
 
Dave Pawson scripsit:

> I want to specify an attribute that can have a value "3pt 36mm" or just 3pt,
> i.e. the second length is optional?
>
> How do I specify this please?
>
> Trying
>  |
> (length, length?)
>
> I get  error: group of "string" or "data" element  error?

Your problem is that RELAX NG will not carve up an attribute value or
element content between two different data or value patterns.  It would
have to try every possible way of segmenting them, and that leads to a
combinatorial explosion very quickly as you add more patterns.

Fortunately, your two lengths are separated by whitespace, which makes
the list pattern applicable.  Remember that list in RELAX NG does not
itself do any iteration: it merely does whitespace segmentation and passes
the result(s) to its child pattern(s).

So what you want is written "list {length, length?}" in the compact syntax.

--
By Elbereth and Luthien the Fair, you shall     cowan@...
have neither the Ring nor me!  --Frodo          http://www.ccil.org/~cowan

#1309 From: Dave Pawson <dave.pawson@...>
Date: Thu Jan 20, 2011 3:50 pm
Subject: Re: repeated pattern
dpawson2000
Send Email Send Email
 
On 20 January 2011 15:35, John Cowan <cowan@...> wrote:

> Your problem is that RELAX NG will not carve up an attribute value or
> element content between two different data or value patterns.  It would
> have to try every possible way of segmenting them, and that leads to a
> combinatorial explosion very quickly as you add more patterns.

yes, http://relaxng.org/spec-20011203.html#string-sequences as was pointed out.

>
> Fortunately, your two lengths are separated by whitespace, which makes
> the list pattern applicable.  Remember that list in RELAX NG does not
> itself do any iteration: it merely does whitespace segmentation and passes
> the result(s) to its child pattern(s).
>
> So what you want is written "list {length, length?}" in the compact syntax.

I guessed it might be able to do it.
Thanks John.

Just a  case of finding 'the right' way :-)


Yes, that works nicely for <block background-position=" 20pt 24in "/>


regards

--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

#1310 From: Geoffroy <c.geoffroy@...>
Date: Thu Jan 20, 2011 8:55 pm
Subject: Building a loop with oneOrMore, choice and empty
c.geoffroy@...
Send Email Send Email
 
Hello

I am currently working on the simplified version of Relax NG to construct a code generator of type, serializer, deserializer for a particular language. But i am having problem with some "exotic" construction like :

     <rng:oneOrMore>
        <rng:choice>
           <rng:empty/>
           <rng:ref name="testSuite-id0x2ddb46"/>
        </rng:choice>
     </rng:oneOrMore>

My generated parser is having a hard time with this grammar.
If we suppose that there is nothing in the input, we descend into the choice and try the empty rule which match 'nothing' perfectly and doesn't eat anything (well because there is nothing to eat).
So the parser joyfully backtrack to the oneOrMore rule, relaunch the rule on the same input : nothing, to see if there is more to parse. And we just entered an endless loop.

So my question are:
  1 - This kind of construct are valid, or not ?
  2 - If so, does Relax Ng propose something for this particular case, or it is the responsibility of the user to not provide looping rule and/or of the generating tool to detect/protect against recursion.


Thank

#1311 From: John Cowan <cowan@...>
Date: Thu Jan 20, 2011 9:22 pm
Subject: Re: Building a loop with oneOrMore, choice and empty
johnwcowan
Send Email Send Email
 
Geoffroy scripsit:

> My generated parser is having a hard time with this grammar.
> If we suppose that there is nothing in the input, we descend into the choice
> and try the empty rule which match 'nothing' perfectly and doesn't eat
> anything (well because there is nothing to eat).
> So the parser joyfully backtrack to the oneOrMore rule, relaunch the rule on
> the same input : nothing, to see if there is more to parse. And we just
> entered an endless loop.

This is a classic bug in regex implementations.  You need to read James
Clark's paper at http://thaiopensource.com/relaxng/derivative.html ,
particularly the discussion of nullability.

--
John Cowan    cowan@...    http://ccil.org/~cowan
Nobody expects the RESTifarian Inquisition!  Our chief weapon is
surprise ... surprise and tedium  ... tedium and surprise ....
Our two weapons are tedium and surprise ... and ruthless disregard
for unpleasant facts....  Our three weapons are tedium, surprise, and
ruthless disregard ... and an almost fanatical devotion to Roy Fielding....

#1312 From: James Clark <jjc@...>
Date: Fri Jan 21, 2011 1:40 am
Subject: Re: Building a loop with oneOrMore, choice and empty
james_j_clark
Send Email Send Email
 
On Fri, Jan 21, 2011 at 3:55 AM, Geoffroy <c.geoffroy@...> wrote:

I am currently working on the simplified version of Relax NG to construct a code generator of type, serializer, deserializer for a particular language. But i am having problem with some "exotic" construction like :

     <rng:oneOrMore>
        <rng:choice>
           <rng:empty/>
           <rng:ref name="testSuite-id0x2ddb46"/>

        </rng:choice>
     </rng:oneOrMore>
 
The context is crucial.  If it's like this:

<define name="testSuite-id0x2ddb46">
    <rng:oneOrMore>
        <rng:choice>
           <rng:empty/>
           <rng:ref name="testSuite-id0x2ddb46"/>
        </rng:choice>
     </rng:oneOrMore>
</define>

then it's not correct RELAX NG (and is prohibited by section 4.19 of the spec).  RELAX NG requires grammars to be regular, and does not allow arbitrary context-free grammars.  A recursive reference has to be within an <element> (after appropriately expanding references).  For example, this would be fine:

<define name="testSuite-id0x2ddb46">
  <element name="foo">
    <rng:oneOrMore>
        <rng:choice>
           <rng:empty/>
           <rng:ref name="testSuite-id0x2ddb46"/>
        </rng:choice>
     </rng:oneOrMore>
  </element>
</define>

This implies, for example, you cannot replace <oneOrMore> my recursion and <choice>.

  2 - If so, does Relax Ng propose something for this particular case, or it is the responsibility of the user to not provide looping rule and/or of the generating tool to detect/protect against recursion.

A conforming RELAX NG validator is required to detect incorrect schemas.

James

#1313 From: Dave Pawson <dave.pawson@...>
Date: Sat Jan 22, 2011 9:56 am
Subject: Another way?
dpawson2000
Send Email Send Email
 
CSS defines color in a number of ways
for xsl-fo I'm looking at a nasty regex

Options for values are
http://www.w3.org/TR/CSS2/syndata.html#value-def-color
rbg(int, int,int)
name (from
(maroon|red|orange|yellow|olive|purple|fuchsia|white|lime|green|navy|blue|aqua|t\
eal|black|silver|gray|ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonF\
ace|ButtonHighlight|ButtonShadow|ButtonText|CaptionText|GrayText|Highlight|Highl\
ightText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoT\
ext|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLi\
ghtShadow|ThreeDShadow|Window|WindowFrame|WindowText
3 hex values (#aaa,#AAA,#123456)

One I don't really understand,
rgb-icc(numeric, numeric, numeric, NCName, numeric, numeric)
a function returning an rgb value.

Bottom line, many options.

For the hex values, the enumerations I can't see anything better than
  xsd:token {pattern ="(# ...

but for the rgb values and the rgb-icc function, the numbers need to
be constrained to 0-255.
Making the regex even longer I guess I could do this,
but that part is already
(rgb\(\s*[0-9]{1,3}\s*,\s*[0-9]{1,3}\s*,\s*[0-9]{1,3}\s*\)) to being
explicit with each digit
would expand it even further?

Is there any way I can mix up the specification of these alternatives?

I'm thinking of using the 'combine' attribute? Is this feasible?
have one definition for each of
hex values
rgb values
enumerated lists

That would tend towards more readable?

Any suggestions please, or even if this is possible?

TIA








--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

#1314 From: Dave Pawson <dave.pawson@...>
Date: Sun Jan 23, 2011 2:07 pm
Subject: Re: Another way?
dpawson2000
Send Email Send Email
 
On 22 January 2011 09:56, Dave Pawson <dave.pawson@...> wrote:
> CSS defines color in a number of ways
> for xsl-fo I'm looking at a nasty regex
start = blocks
blocks =  element blocks {block+}
block = element block {col}
col =
   attribute col { colspec}

colspec=
xsd:token
{pattern="rgb\(\s*((([0-9])|([0-9]{2})|((0[0-9]{2})|(1[0-9]{2})|(2[0-5]{2})))\s*\
,\s*(([0-9])|([0-9]{2})|((0[0-9]{2})|(1[0-9]{2})|(2[0-5]{2})))\s*,\s*(([0-9])|([\
0-9]{2})|((0[0-9]{2})|(1[0-9]{2})|(2[0-5]{2}))))\)"}

<blocks>
<block col="rgb(255,255,255)"/>
<block col='rgb(190,19, 1)'/>
<block col='rgb(254,199,12)'/>
<block col='rgb(19,111,111)'/>
<block col='rgb(9 ,1,255)'/>
<block col='rgb( 9,1,000)'/>
<block col='rgb( 9,1,099)'/>
<block col='rgb( 9,1,256)'/>
</blocks>

jing fails the last entry, nxml-mode says it's OK!

Pity we can't have a relaxed layout for regexen, to make it easier to read.

regards



--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk

#1315 From: Bjoern Hoehrmann <derhoermi@...>
Date: Thu Jan 27, 2011 2:06 am
Subject: RELAX NG to JSON compiler, or whatever
hoermi
Send Email Send Email
 
Hi,

   I made an ad-hoc tool that turns a RELAX NG schema in simply syntax
into a parser table for efficient (and so far approximate) validation.
The source code for the tool as well as a demonstration using the XHTML
1.0 Transitional schema generated through trang and rng2srng is at:

   http://www.websitedev.de/temp/xhtml1-transitional-validator.html.gz

The tool largely ignores data types, fixed values, lists, and name
classes (though infrastructure for name classes is there). The tool
generates a JSON table that allows running the validation process like

It is based on http://www.thaiopensource.com/relaxng/derivative.html
with one important difference in that there is no After pattern. In-
stead it simulates, for a given qualified name, the union of all
matching <define>s and notes where in the simulation process the
elements underneath become nullable. Those accepting states are then
used in the transition table of the parent, so validation becomes
something like:

   state = automaton[state][attribute1];
   state = automaton[state][attribute2];
   ...
   childstate = recursive(child1);
   state = automaton[state][childstate];

   childstate = recursive(child2);
   state = automaton[state][childstate];
   ...

Obviously in order to keep the validation process this simple you'd
have to turn data types and so on into similar DFAs, but that would
make things quickly become weird and complicated and slow, especially
in inefficient machine code like JavaScript, and there is very little
tool support for that. Besides, grammars usually don't come with much
beyond a couple of fixed keyword and maybe some xsd:int somewhere.

Infrastructure for name classes is there (I regard AnyName, NsName,
and a new LnName construct as patterns and have patterns for comple-
ment and intersection, and simply decide membership by computing the
derivatives with respect to namespace names and local names) but it's
obviously not easy to lookup unknown names in a static table, so the
support for name classes for elements does little, and support for
name classes for attributes is absent.

It might be possible to simply have some "##other" names in the table
to support unknown names, but I haven't thought through that yet for
elements, and for attributes this might make things kinda messy.

The JavaScript demo as it is churns through a couple of megabyte per
second on commodity hardware, that's probably somewhere around the
edge of "tolerable" for something like a real-time browser addon.

There is also no error recovery of any kind, although that would be
easy to add, if you go by James Clark's work you could similarily
pre-compute recovery states, and things like ignoring failures due
to attributes could be done directly in the validator without changes
in the parser tables. Giving better error messages by analyzing the
graph is also an option.

This builds up on earlier work I've done, for instance, once I turned
DTDs into tables with regular expressions and let browser's regular ex-
pression engines do the matching, attribute values in the obvious way,
and content models by turning lists of children into lists separated by
a separator:

   http://lists.w3.org/Archives/Public/www-validator/2006Nov/0000.html

Anyway, I mostly wanted to invest a couple of hours to support the point
that validation is really simple with the right tools, and this might be
a meaningful contribution to that end. The backend-tool is written in C#
and available under the GPLv2+, and available from the page noted above.

regards,
--
Björn Höhrmann · mailto:bjoern@... · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/

#1316 From: "Tara" <taraathan@...>
Date: Mon Feb 7, 2011 10:52 pm
Subject: how to specify xsd:anyType
taraathan
Send Email Send Email
 
I am preparing a Relax NG compact schema to use as a pivot format.
The original schema (actually a complex hierarchy) is xsd.
I am running into trouble with xsd:anyType

I have the xsd

<xs:element name="Data" type="xs:anyType"/>

What can I put into Relax NG that will produce this when converted to xsd (I am
using oXygen) or at least emulate it?

I have tried

Data.type = element Data {data}

as suggested in Relax NG textbook by van der Vlist, but this gives an error
[Jing] reference to undefined pattern "data"

I thought about trying to define the pattern myself

data = xsd:decimal|xsd:float| and so on
but I looked up what types I would have to list and there were so
many that this just seemed ridiculous.

So I thought, maybe

data = xsd:*
would work, but that says "syntax error" .

I have run out of ideas ... any suggestions?

Thanks, Tara

#1317 From: John Cowan <cowan@...>
Date: Tue Feb 8, 2011 1:23 am
Subject: Re: how to specify xsd:anyType
johnwcowan
Send Email Send Email
 
Tara scripsit:

> I am preparing a Relax NG compact schema to use as a pivot format.
> The original schema (actually a complex hierarchy) is xsd.
> I am running into trouble with xsd:anyType

The trouble is that anyType means "any simple or complex type", and
RELAX NG doesn't support that; it only supports XSD simple types.
Perhaps you want anySimpleType?

--
Your worships will perhaps be thinking          John Cowan
that it is an easy thing to blow up a dog?      http://www.ccil.org/~cowan
[Or] to write a book?
     --Don Quixote, Introduction                 cowan@...

#1318 From: Tara Athan <taraathan@...>
Date: Wed Feb 9, 2011 8:35 am
Subject: Re: how to specify xsd:anyType
taraathan
Send Email Send Email
 
John Cowan wrote:
 

Tara scripsit:

> I am preparing a Relax NG compact schema to use as a pivot format.
> The original schema (actually a complex hierarchy) is xsd.
> I am running into trouble with xsd:anyType

The trouble is that anyType means "any simple or complex type", and
RELAX NG doesn't support that; it only supports XSD simple types.
Perhaps you want anySimpleType?

Yes, you are right. But I can't get that working either.

I've boiled it down to some simple test cases. Here is a bit of xml code. I want the schema to validate contents of Data elements
based on the explicit type given by the xsi:type attribute.

<?xml version="1.0" encoding="UTF-8"?>
<arg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.taraathan.com/1.0/xsd ../../modules/data_test.xsd"
      xmlns="http://www.taraathan.com/1.0/xsd"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema-datatypes"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <Data xsi:type="xs:dateTime">2010-01-22T10:03:45Z</Data>
    <Data xsi:type="xs:decimal">123.4</Data>
</arg>

This XML schema works as required (in oXygen)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified"
    targetNamespace="http://www.taraathan.com/1.0/xsd"
    xmlns:xsd="http://www.taraathan.com/1.0/xsd">
  <xs:element name="arg" type="xsd:arg.content"/>
  <xs:complexType name="arg.content">
    <xs:complexContent>
      <xs:extension base="xsd:Data.type"/>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="Data.type">
    <xs:sequence>
      <xs:element ref="xsd:Data"/>
      <xs:element ref="xsd:Data"/>
    </xs:sequence>
  </xs:complexType>
  <xs:element name="Data" type="xs:anySimpleType"/>
</xs:schema>

I would like to have a Relax NG compact schema which allows this construction. I would be OK if it doesn't perform the datatype validation, but it should at least ignore the xsi:type attribute.  But I can't get that to happen.  A direct attack fails

Data.type = element Data { xsd:anySimpleType }

results in (in oXygen)
[Jing] datatype "anySimpleType" from library "http://www.w3.org/2001/XMLSchema-datatypes" not recognized

A sneak attack fails also:

default namespace = "http://www.taraathan.com/1.0/xsd"
namespace xs="http://www.w3.org/2001/XMLSchema"
namespace xsi="http://www.w3.org/2001/XMLSchema-instance"
datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"

anySimpleType =
xsd:duration|
xsd:dateTime|
xsd:time|
xsd:date|
xsd:gYearMonth|
xsd:gYear|
xsd:gMonthDay|
xsd:gDay|
xsd:gMonth|
xsd:boolean|
xsd:base64Binary|
xsd:hexBinary|
xsd:float|
xsd:decimal|
xsd:double|
xsd:anyURI|
xsd:QName|
xsd:NOTATION|
xsd:string

start = arg.type

arg.type = element arg {  arg.content }

arg.content = Data.type,Data.type

Data.type = element Data { anySimpleType }

The schema is OK, but when used to validate the above code I get (in oXygen)
 [Jing] found attribute "xsi:type", but no attributes allowed here.
However when I convert (in oXygen) to xsd, I get a schema which validates the xml, including validating against the explicit type.

Suggestions are greatly appreciated.

Tara


#1319 From: John Cowan <cowan@...>
Date: Mon Feb 14, 2011 4:37 am
Subject: Re: how to specify xsd:anyType
johnwcowan
Send Email Send Email
 
Tara Athan scripsit:

> However when I convert (in oXygen) to xsd, I get a schema which
> validates the xml, including validating against the explicit type.

There's a bug in trang: it doesn't ignore declarations for the xsi:
namespace when converting to XSD.  You have to do a little post-editing.

--
Some people open all the Windows;       John Cowan
wise wives welcome the spring           cowan@...
by moving the Unix.                     http://www.ccil.org/~cowan
   --ad for Unix Book Units (U.K.)
         (see http://cm.bell-labs.com/cm/cs/who/dmr/unix3image.gif)

#1320 From: Tara Athan <taraathan@...>
Date: Mon Feb 14, 2011 7:34 pm
Subject: Re: how to specify xsd:anyType
taraathan
Send Email Send Email
 
John Cowan wrote:
 

Tara Athan scripsit:

> However when I convert (in oXygen) to xsd, I get a schema which
> validates the xml, including validating against the explicit type.

There's a bug in trang: it doesn't ignore declarations for the xsi:
namespace when converting to XSD. You have to do a little post-editing.


Thanks for the tip - I added my vote and a comment to the jing-trang issue #132

At first I was surprised that this was considered a bug in trang rather than a bug in jing. From my perspective, I would rather that the rng validator allow an xsi:type attribute, where appropriate, by default rather than requiring it to be explicitly declared. But I re-read the Relax NG specs, and yes that's what it says :(

This is a big setback for me, because this element is to be part of a core module in a highly user-extensible system. So a little post-editing becomes a big headache and high risk for user-error.


Tara


--
Some people open all the Windows; John Cowan
wise wives welcome the spring cowan@...
by moving the Unix. http://www.ccil.org/~cowan
--ad for Unix Book Units (U.K.)
(see http://cm.bell-labs.com/cm/cs/who/dmr/unix3image.gif)



#1321 From: John Cowan <cowan@...>
Date: Mon Feb 14, 2011 8:44 pm
Subject: Re: how to specify xsd:anyType
johnwcowan
Send Email Send Email
 
Tara Athan scripsit:

> At first I was surprised that this was considered a bug in trang rather
> than a bug in jing. From my perspective, I would rather that the rng
> validator allow an xsi:type attribute, where appropriate, by default
> rather than requiring it to be explicitly declared. But I re-read the
> Relax NG specs, and yes that's what it says :(

In the pure RELAX NG model, the only namespace that is special is xml:,
and that's because it's special in XML as a whole.  Even then, you have
to write patterns for xml: attributes, just like anythying else.  The time
to treat xsi: specially is when you switch to the XSD environment.

> This is a big setback for me, because this element is to be part of a
> core module in a highly user-extensible system. So a little post-editing
> becomes a big headache and high risk for user-error.

Put together a little tool (it's easy with XSLT) to strip it out as part
of your conversion framework.

--
Dream projects long deferred             John Cowan <cowan@...>
usually bite the wax tadpole.            http://www.ccil.org/~cowan
         --James Lileks

#1322 From: Tara Athan <taraathan@...>
Date: Mon Feb 14, 2011 9:49 pm
Subject: Re: how to specify xsd:anyType
taraathan
Send Email Send Email
 
John Cowan wrote:
 

Tara Athan scripsit:

> At first I was surprised that this was considered a bug in trang rather
> than a bug in jing. From my perspective, I would rather that the rng
> validator allow an xsi:type attribute, where appropriate, by default
> rather than requiring it to be explicitly declared. But I re-read the
> Relax NG specs, and yes that's what it says :(

In the pure RELAX NG model, the only namespace that is special is xml:,
and that's because it's special in XML as a whole. Even then, you have
to write patterns for xml: attributes, just like anythying else. The time
to treat xsi: specially is when you switch to the XSD environment.

> This is a big setback for me, because this element is to be part of a
> core module in a highly user-extensible system. So a little post-editing
> becomes a big headache and high risk for user-error.

Put together a little tool (it's easy with XSLT) to strip it out as part
of your conversion framework.

There is no conversion framework. The modules are open source and they are just made available for download or reference by URI, for users to assemble as they wish. Even if we did provide a conversion tool, when the schema are published like this, there is no way to ensure that users will use the tool instead of going directly to oXygen or Trang. 

I took a look at the Trang source code, and with a little advice I might be able to create a patch. Is there a separate rng-dev forum, or does that sort of discussion happen on this list?

Tara


--
Dream projects long deferred John Cowan <cowan@...>
usually bite the wax tadpole. http://www.ccil.org/~cowan
--James Lileks



#1323 From: John Cowan <cowan@...>
Date: Tue Feb 15, 2011 8:05 pm
Subject: Re: how to specify xsd:anyType
johnwcowan
Send Email Send Email
 
Tara Athan scripsit:

> There is no conversion framework. The modules are open source and they
> are just made available for download or reference by URI, for users to
> assemble as they wish. Even if we did provide a conversion tool, when
> the schema are published like this, there is no way to ensure that users
> will use the tool instead of going directly to oXygen or Trang.

No, but you can publish both the source RNG and the slightly edited XSD
versions, so that people who prefer XSD can use it.

>
> I took a look at the Trang source code, and with a little advice I might
> be able to create a patch. Is there a separate rng-dev forum, or does
> that sort of discussion happen on this list?

Here's as good a place as any.

--
All Gaul is divided into three parts: the part          John Cowan
that cooks with lard and goose fat, the part            http://ccil.org/~cowan
that cooks with olive oil, and the part that            cowan@...
cooks with butter. --David Chessler

#1324 From: "arghman" <jmsachs@...>
Date: Fri Feb 18, 2011 7:37 pm
Subject: error: repeat of "string" or "data" element
arghman
Send Email Send Email
 
Help! I'm trying to validate particular text content in an XML file, using jing,
and I get an error:

   error: repeat of "string" or "data" element

Could anyone help me understand why and figure out a workaround? My example .rnc
and .xml files are posted in a StackOverflow question
(http://stackoverflow.com/questions/5044787/relaxng-invalid-schema-definition)
-- I posted there first hoping someone would answer, but  there are very few
RELAX NG questions.

--Jason

#1325 From: Syd Bauman <Syd_Bauman@...>
Date: Fri Feb 18, 2011 8:14 pm
Subject: Re: error: repeat of "string" or "data" element
syd_bauman
Send Email Send Email
 
[Fast and only marginally useful answer, as I don't have time right
now to try to figure out what your trying to do, and thus what a
solution might be.]

Your schema boils down to having

   xsd:token { pattern = "[A-Za-z_][A-Za-z_0-9]*(\.[A-Za-z_][A-Za-z_0-9]*)*" }

in a repeatable choice. That "xsd:token", in the XML syntax, is
represented by a <data> element with type="token". So you end up with

   <zeroOrMore>
     <choice>
       <data type="token">
         <param
name="pattern">[A-Za-z_][A-Za-z_0-9]*(\.[A-Za-z_][A-Za-z_0-9]*)*</param>
       </data>
       <!-- ... -->
     </choice>
   </zeroOrMore>

That puts a <data> element as a descendant of <zeroOrMore> or
<oneOrMore>, which isn't allowed.

> Help! I'm trying to validate particular text content in an XML file, using
jing, and I get an error:
>
>   error: repeat of "string" or "data" element
>
> Could anyone help me understand why and figure out a workaround? My
> example .rnc and .xml files are posted in a StackOverflow question
> (http://stackoverflow.com/questions/5044787/relaxng-invalid-schema-definition)
> -- I posted there first hoping someone would answer, but there are
> very few RELAX NG questions.

#1326 From: John Cowan <cowan@...>
Date: Fri Feb 18, 2011 11:12 pm
Subject: Re: error: repeat of "string" or "data" element
johnwcowan
Send Email Send Email
 
arghman scripsit:

> Help! I'm trying to validate particular text content in an XML file,
> using jing, and I get an error:
>
>   error: repeat of "string" or "data" element
>
> Could anyone help me understand why and figure out a workaround? My
> example .rnc and .xml files are posted in a StackOverflow question
> (http://stackoverflow.com/questions/5044787/relaxng-invalid-schema-definition)
> -- I posted there first hoping someone would answer, but  there are
> very few RELAX NG questions.

You've bumped up against one of RELAX NG's basic limitations: an element's
content can be complex (with text patterns, element patterns, sequence
patterns, interleave patterns, and quantifier patterns) or simple (with
data patterns, value patterns, and list patterns), but not both at the
same time. (Of course, it's possible to have a choice between complex
and simple content.)

You really can't do better than to use text here, and maybe write a
Schematron rule or two.

(I've posted this to stackoverflow as well.)

--
John Cowan              cowan@...          http://www.ccil.org/~cowan
Most people are much more ignorant about language than they are about
[other subjects], but they reckon that because they can talk and read and
write, their opinions about talking and reading and writing are as well
informed as anybody's.  And since I have DNA, I'm entitled to carry on at
length about genetics without bothering to learn anything about it.  Not.
                         --Mark Liberman

#1327 From: James Clark <jjc@...>
Date: Sat Feb 19, 2011 1:06 am
Subject: Re: error: repeat of "string" or "data" element
james_j_clark
Send Email Send Email
 
Try using the

  list { ... }

operator. See the tutorial:


James

On Sat, Feb 19, 2011 at 2:37 AM, arghman <jmsachs@...> wrote:
 

Help! I'm trying to validate particular text content in an XML file, using jing, and I get an error:

error: repeat of "string" or "data" element

Could anyone help me understand why and figure out a workaround? My example .rnc and .xml files are posted in a StackOverflow question
(http://stackoverflow.com/questions/5044787/relaxng-invalid-schema-definition) -- I posted there first hoping someone would answer, but there are very few RELAX NG questions.

--Jason



#1328 From: John Cowan <cowan@...>
Date: Sat Feb 19, 2011 1:54 am
Subject: Re: error: repeat of "string" or "data" element
johnwcowan
Send Email Send Email
 
James Clark scripsit:

> Try using the
>
>   list { ... }
>
> operator. See the tutorial:

It won't help in this case, because there are interleaved child elements,
which mixes complex and simple content.

--
He made the Legislature meet at one-horse       John Cowan
tank-towns out in the alfalfa belt, so that     cowan@...
hardly nobody could get there and most of       http://www.ccil.org/~cowan
the leaders would stay home and let him go      --H.L. Mencken's
to work and do things as he pleased.              Declaration of Independence

Messages 1299 - 1328 of 1479   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help