473,657 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Tr ansform -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="ht tp://www.w3.org/1999/xhtml"
elementFormDefa ult="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:styleshe et 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>Namespa ce</TH><TH>SchemaLo cation</TH></TR>
<xsl:apply-templates select="/schema/import"/>
</TABLE>
</BODY>
</HTML>
</xsl:template>

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

<xsl:template match="/schema/import">
<TR>
<TD><xsl:valu e-of select="@namesp ace"/></TD>
<TD><xsl:valu e-of select="@schema Location"/></TD>
</TR>
</xsl:template>
</xsl:stylesheet>

Jul 20 '05 #1
1 1672
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
2443
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 elements and attributes (onclick, <script>, etc.). I would also like to do basic validation (no overlapping elements like <strong><em>foo</em></strong>, no missing end tags). I'm not asking anyone to write a script for me, but does anyone have general...
1
1600
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, they wanted me to try to output some simple text which summarizes the basic data in the xml and do it without perl. After that I guess they will want me to convert other xml files into some kind of text file I am assuming. I downloaded xalan, but...
1
1823
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 space attribute in the root of the output, or generating other attributes in the root? The following illustrates the case. The XSLT script specifies an output root element
9
1835
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 owner element. Is that right ? Like:
2
2110
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 all XML related code and replace with HTML valid code, but with my commandline XSLT transformer(http://xmlsoft.org/XSLT/) it outputs a xmlns on elements I'v used <xsl:copy-of select="/some/node"> to produce. Is this how it should work, or is this...
2
430
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 that element's attributes, value and children. I've done this via Java with <saxon:output> element in Saxon's XSLT extension, but I'm not sure how to do it in C#/.NET. Assuming I use an extension object, what do I have to modify in the C# class...
4
1975
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 output the formatted string. So far everything process correctly (the method is called without any issue) but my problem is that the output is htmlencoded, it means that my method (wich work as intended in other contexts) is called but the...
4
9169
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 contain < not <), while it works when using MSXML2 to do the transform. Does anyone have the same problem and how to make the escape work? Thanks. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
1
1470
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 name="car.jpg" size="5000" /><image type = "jpg" compression = "20" /> .... ....
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1611
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.