Simple (?) output of attributes with XSLT does not work

H

Harry Zoroc

I would like to treat an xsd Schema file as XML file and to display the targetNamespace and all the imports. That's it.
But the following does not work. Why?

I did not enter the stylesheet in the xsd file directly but tried to compute the output
on the command line e.g. with xalan like:

java net.sf.saxon.Transform -o myout.html myschema.xsd myxsltfile.xslt

Using Saxon yields no better result. The produced myout.html contains all HTML tags and a lot of tabulators
but no filtered contents from the xsd file.

Both XSLT processor work for other xml/XSLT formattings. So it's not an error of the xslt procs setup.

So what's wrong with the xslt stylesheet?

Harry

myschema.xsd (beginning):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<schema targetNamespace="http://www.blah.org/aaa"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
elementFormDefault="qualified">
<import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="ddd.xsd"/>
<import namespace="http://www.foo.com/bbb" schemaLocation="bbb.xsd"/>
<import namespace="http://www.zock.net/ccc" schemaLocation="ccc.xsd"/>
.....


myxsltfile.xslt:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:eek:utput method="html"/>
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE>Test</TITLE>
</HEAD>
<BODY>
targetNamspace=<xsl:apply-templates select="/schema"/>
Imports:
<TABLE border="1">
<TR><TH>Namespace</TH><TH>SchemaLocation</TH></TR>
<xsl:apply-templates select="/schema/import"/>
</TABLE>
</BODY>
</HTML>
</xsl:template>

<xsl:template match="/schema">
<xsl:value-of select="@targetNamespace"/>
</xsl:template>

<xsl:template match="/schema/import">
<TR>
<TD><xsl:value-of select="@namespace"/></TD>
<TD><xsl:value-of select="@schemaLocation"/></TD>
</TR>
</xsl:template>
</xsl:stylesheet>
 
H

Henry S. Thompson

Valid schema documents, including yours, are in the
http://www.w3.org/XMLSchema namespace. You need to include a
namespace declaration for that namespace, e.g.

xmlns:xs="http://www.w3.org/XMLSchema"

on the root of your stylesheet, and us e.g.

<xsl:template match="/xs:schema/xs:import">

to access it.

Note because of the way XPath 1.0 is defined, just adding a default
namespace declaration for the W3C XML Schema namespace will _not_ fix
your stylesheet.

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top