473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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:output 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>

Jul 20 '05 #1
1 1661
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: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Leif K-Brooks | last post by:
I'm writing a site with mod_python which will have, among other things, forums. I want to allow users to use some HTML (<em>, <strong>, <p>, etc.) on the forums, but I don't want to allow bad...
1
by: Larry | last post by:
I am a C++/Java programmer trying to get going with some simpe xml transformations at work here. I bought the O'Reilly book Learning xlst for kicks. Someone at work sent me this xml shown below,...
1
by: Wolfgang | last post by:
XSLT transformations by default seem to pass name space attributes into the root element of their output (example below). QUESTION: Is it possible to control this, i.e. not genrating a name...
9
by: Soren Kuula | last post by:
Hi, I just can't find namespaces of attributes stated clearly enough in the XML namespace spec. But .. I hear rumors that attributes, unless qualified otherwise, default to the namespace of the...
2
by: Taare | last post by:
Hi, I got <xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system=" http://www.w3.org/TR/html4/strict.dtd"/> in my XSLT file. This should remove...
2
by: spjewett | last post by:
I need to generate multiple output files while transforming a single XML file with an XSLT. I generate a node list of a certain element type, then generate a new file for each element based on...
4
by: Gauthier | last post by:
Hi, I've a simple issue with the use of extension objects. I'm trying to call a text formating method from an object that I add to my arguments collection, this method take an input string and...
4
by: Jon | last post by:
Hi, I used XslCompiledTransform with the following Xsl file. The <xsl:text disable-output-escaping="yes"does not work when using XslCompiledTransform to do the trnasform (namely the output...
1
by: kbozek | last post by:
I have an XSLT transform that will create an XML to XML transformation in the parent child format. I really want to output the elements and attributes on a single line such as: <image...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.