Loading ...
Sorry, an error occurred while loading the content.

how to specify xsd:anyType

Expand Messages
  • Tara
    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
    Message 1 of 8 , Feb 7, 2011
    • 0 Attachment
      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
    • John Cowan
      ... 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
      Message 2 of 8 , Feb 7, 2011
      • 0 Attachment
        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@...
      • Tara Athan
        John Cowan wrote: ... The trouble is that anyType means any simple or complex type , and RELAX NG doesn t support that; it only supports XSD simple types.
        Message 3 of 8 , Feb 9, 2011
        • 0 Attachment
          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

        • John Cowan
          ... 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
          Message 4 of 8 , Feb 13, 2011
          • 0 Attachment
            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)
          • Tara Athan
            ... Thanks for the tip - I added my vote and a comment to the jing-trang issue #132
            Message 5 of 8 , Feb 14, 2011
            • 0 Attachment
              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)


            • John Cowan
              ... 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
              Message 6 of 8 , Feb 14, 2011
              • 0 Attachment
                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
              • Tara Athan
                ... 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
                Message 7 of 8 , Feb 14, 2011
                • 0 Attachment
                  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


                • John Cowan
                  ... No, but you can publish both the source RNG and the slightly edited XSD versions, so that people who prefer XSD can use it. ... Here s as good a place as
                  Message 8 of 8 , Feb 15, 2011
                  • 0 Attachment
                    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
                  Your message has been successfully submitted and would be delivered to recipients shortly.