xsl-list
[Top] [All Lists]

RE: [xsl] re-ordering an instance to match a schema

2007-04-15 03:22:31
It's a two-part problem: first you have to find some way of reading the
content model from the schema, then you have to do the sort.

If the content model is something like (a* | b*a* | (cba)*) then I think
it's a pretty tough problem, and you'll have to search the computer science
literature to see if any algorithms exist. 

If it's a more constrained content model, for example if it's a sequence of
elements each of which can only occur zero-or-one times, then it becomes
more tractable. For example, once you've worked out how to read the content
model, you can build a structure that maps the element names to positions
like this:

<contentModel>
  <element name="p" position="1"/>
  <element name="q" position="2"/>
  ...
</contentModel>

and then do

  <xsl:sort
select="$contentModel/element[(_at_)name=local-name(current())]/number(@position)
"/>

Michael Kay
http://www.saxonica.com/

-----Original Message-----
From: Joe McDuffey [mailto:jdmcduf(_at_)erols(_dot_)com] 
Sent: 15 April 2007 08:59
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] re-ordering an instance to match a schema 

There was a thread back in 2003 concerning

   Subject: Re: [xsl] re-ordering an instance to match a schema
   From: S Woodside <sbwoodside(_at_)xxxxxxxxx
   <mailto:sbwoodside(_at_)DOMAIN(_dot_)HIDDEN>>
   Date: Wed, 14 May 2003 19:35:25 -0400

I don't know if this was ever resolved, but I would like to 
know if there exists a stylesheet to reorder an instance that 
would be in the sequential order of a Schema e.g. relanNG or 
W3C. I need this as a  step prior to validation.. Can anyone 
help. Thanks.

--
Joe McDuffey
JONY Software Solutions
"An ISO 9001:2000 Certified Company"
jdmcduf(_at_)jonysolutions(_dot_)com
410.884.5355 (Office)
443.804.9646 (cell)
410.744.5355(FAX)
http://www.jonysolutions.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>