[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: re-ordering an instance to match a schema

Subject: Re: re-ordering an instance to match a schema
From: S Woodside <sbwoodside@xxxxxxxxx>
Date: Wed, 14 May 2003 18:15:33 -0400
xsl optional match
Hi Wendell,

On Wednesday, May 14, 2003, at 04:49 PM, Wendell Piez wrote:

Hi Simon,

At 02:32 PM 5/14/2003, you wrote:
Is there XSLT out there, that I can use, that will take an instance and a schema and re-order the instance to match the schema? Does that make sense?

Two things that can help us answer this question:


1. Are we talking arbitrary RNG schemas, or some subset thereof?

Ideally, any schema, assuming it's in XML format. The subset I've been working with so far seems to be those that terminate, I don't know the right word, but they don't allow infinite recursion of elements or infinitely large trees.


2. By "reorder the instance to match the schema", we are talking about the order declared by the schema to be a valid order, or the order of the declarations? (The former, I take it. But this is why the first question is important.)

Actually the latter. I'm thinking about schemas where it will validate in bunch of orders, but where there is an author-implied order in the declarations. For example, if there's a <oneOrMore><choice>...</choice></oneOrMore> with a series of options, the implied order is the order the choices are written in the schema.


Seeing a sample of input (in this case, both inputs) and desired output would, as always, be a big help.

OK. At the end is schema snippet, then a valid instance snippet in an implicitly wrong order, then a valid instance snippet in an implicity right order according to order of declarations.


simon

======== RNG schema snippet =========

<element name="contact">
  <zeroOrMore>
    <choice>
      <element name="phone">
        <optional>
          <attribute name="location">
            <choice>
              <value>
                home
              </value>
              <value>
                work
              </value>
              <value>
                mobile
              </value>
            </choice>
          </attribute>
        </optional>
        <text />
      </element>
      <element name="fax">
        <optional>
          <attribute name="location">
            <choice>
              <value>
                home
              </value>
              <value>
                work
              </value>
            </choice>
          </attribute>
        </optional>
        <text />
      </element>
      <element name="pager">
        <text />
      </element>
      <element name="email">
        <text />
      </element>
      <element name="url">
        <text />
      </element>
      <element name="instantMessage">
        <optional>
          <attribute name="service" />
        </optional>
        <text />
      </element>
    </choice>
  </zeroOrMore>
</element>

======== implicitly wrong order (but valid) =========

<contact>
  <url>http://www.simonwoodside.com/<url>
  <email>sbwoodside@xxxxxxxxx</email>
  <phone location="work">555-1212</phone>
  <fax>555-1111</fax>
</contact>

======== implicitly right order (also valid) =========

<contact>
  <phone location="work">555-1212</phone>
  <fax>555-1111</fax>
  <email>sbwoodside@xxxxxxxxx</email>
  <url>http://www.simonwoodside.com/<url>
</contact>


-- www.simonwoodside.com -- 99% Devil, 1% Angel


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.