Re: [xsl] an elements schema context via xslt

Subject: Re: [xsl] an elements schema context via xslt
From: Jan Limpens <jan.limpens@xxxxxxxxx>
Date: Thu, 30 Jun 2005 15:37:06 -0300
Hi guys,

many thanks for your input! Whow it seems like I unwakened quite a beast
here!

The XS3P project is nice, but without having looked at it's interiors,
its just a stylesheet that converts a schema to something more human
readable.

The real complexity comes in when I have to see this combined with the
actual xml document.
When I see the schema as the xml document's abstract form, I would
have to calculate the abstract xpath [/root/parent] to an element (I
don't know if there is such a construct) from the implemented
[/root[1]/parent[4], actually right now it is even /*[1]/*[4], but
this could be fixed] xpath in the doc. Then I would somehow find this
element in the schema (somehow, because the schema's actual xpath
would be totally different:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="XSDSchema1"
targetNamespace="http://tempuri.org/XSDSchema1.xsd";
elementFormDefault="qualified"
	xmlns="http://tempuri.org/XSDSchema1.xsd";
xmlns:mstns="http://tempuri.org/XSDSchema1.xsd";
	xmlns:xs="http://www.w3.org/2001/XMLSchema";>
	<xs:element name="root">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="parent" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="parent">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="child" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="child">
		<xs:complexType>
			<xs:sequence />
		</xs:complexType>
	</xs:element>
</xs:schema>

So I match an element[@name=$xpath[1]], where $xpath is a parameter
array of my abstract xpath and see if it has
element/complexType/sequence/element[name or ref = $xpath[2] and
recurse until I find my element. No idea how to implement this (while
Arian gave me an idea of this, which makes me shiver in dispair).
The next part of finding valid child elements seems easy, it ought to
be almost the same as the step before. The result would be xml such as

<possibilities>
   <attributes/>
   <elements>
      <element name="child"/>
   </elements>
   <siblings>
      <element name="parent">
   </siblings>
</possibilities>

All in all I still feel pretty lost... Am I on the path to the dark side?

On the imperative side I tried inspiring myself in an open source xml
editor, but the one I found - Jaxe - was in java and french and can't
identify the part where this is done, I suspect in some library,
probably xalan, xerxes or whereever)

:-S Jan

Current Thread