This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
how to use an xsd as an xml, or is it an include-problem?
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] how to use an xsd as an xml, or is it an include-problem?
- From: Rene de Vries <RdVries at PCL-HaGe dot nl>
- Date: Tue, 24 Apr 2001 10:51:01 +0200
- Organization: PCL HaGé b.v.
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi xsl-ers,
I'm new in xml/xsl/xsd/x..-land, and so I hope that my question is an
easy-one for you. I'm just in the stadium monkey see, monkey do.....
I'm trying to display an xsd in a readable way for end-users. The xml they
have to create is database-like, so I want to show a html-table with the
database layout: the "fields" for each "datafile". First I want to add a
description to the fields, later more compex things like types, required
etc.
I don't want to change the xsd, so I made a separate description-xml and a
main-xml, including the xsd (as an xml) and the description xml:
main-xml (including everything I need):
<?xml version="1.0" encoding="UTF-8"?>
<document xmlns:xinclude="http://www.w3.org/1999/XML/xinclude">
<xinclude:include href="AX_VB.xsd"/>
<xinclude:include href="Descriptions_VB.xml"/>
</document>
a part of my xsd (which I want to display):
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<xsd:include schemaLocation="Datatypes.xsd"/>
<xsd:element name="OfferteAanvraag" type="OfferteAanvraagType"/>
<xsd:complexType name="OfferteAanvraagType">
<xsd:sequence>
<xsd:element name="Header" type="HeaderType"/>
........
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="HeaderType">
<xsd:sequence>
<xsd:element name="VerzenderNrHDN" type="HdnNrType"/>
<xsd:element name="VerzenderNaam" type="string35Type"/>
........
</xsd:sequence>
</xsd:complexType>
......
</xsd:schema>
a part of my description-xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Descriptions>
<HeaderType>
<DescriptionShort>"Standaard header bericht"</DescriptionShort>
<DescriptionLong>"Standaard header"</DescriptionLong>
<VerzenderNrHDN>
<DescriptionShort>"Verzendernummer"</DescriptionShort>
<DescriptionLong>"Unieke HDN-nummer verzender"</DescriptionLong>
</VerzenderNrHDN>
<VerzenderNaam>
<DescriptionShort>"Verzendernaam"</DescriptionShort>
<DescriptionLong>"Achternaam met voorvoegsel of maatschappijnaam van
verzender"</DescriptionLong>
</VerzenderNaam>
.......
</HeaderType>
.......
</Descriptions>
my xsl (which doesn't work at all):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:xinclude="http://www.w3.org/1999/XML/xinclude">
<xsl:output method="html"/>
<xsl:strip-space elements="*"/>
<!-- -->
<!-- / -->
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<!-- -->
<!-- xsd:element -->
<xsl:template match="xsd:element">
<xsl:choose>
<xsl:when test="..=/">
<b>
Schema: <xsl:value-of select="@name"/>
</b>
</xsl:when>
<xsl:otherwise>
<tr>
<td width="10%">
<xsl:value-of select="@name"/>
</td>
<!-- here I want to pull in the Description from the
Descriptions.xml -->
<xsl:variable name="parent" select="../@name"/>
<xsl:variable name="naam" select="@name"/>
<xsl:variable name="xxx"
select="document(xsd:schema/xinclude:include/@href)"/>
<td><xsl:value-of
select="$xxx//Descriptions/@parent/@naam/DescriptionShort"/></td>
<td width="10%">
<xsl:value-of select="@type"/>
</td>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- -->
<!-- xsd:complexType -->
<xsl:template match="xsd:complexType">
<xsl:if test="..=/">
<hr/>
<b>
<xsl:value-of select="@name"/>
</b>
</xsl:if>
<xsl:attribute name="id"><xsl:value-of
select="@name"/></xsl:attribute>
<xsl:apply-templates select="*"/>
</xsl:template>
<!-- -->
<!-- xsd:sequence -->
<xsl:template match="xsd:sequence">
<xsl:if test="..=/">
<hr/>
</xsl:if>
<table border="1" width="100%">
<tr>
<td>
<xsl:apply-templates select="*"/>
</td>
</tr>
</table>
</xsl:template>
<!-- -->
</xsl:stylesheet>
The only thing I get is a bank page!
What do I do wrong????
Greetings Rene
{ @ @ }
^
\__/
"You don't need eyes to see, you need vision!"
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list