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

Discussion in 'XML' started by Harry Zoroc, Jul 7, 2004.

  1. Harry Zoroc

    Harry Zoroc Guest

    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>
     
    Harry Zoroc, Jul 7, 2004
    #1
    1. Advertising

  2. 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:
    URL: http://www.ltg.ed.ac.uk/~ht/
    [mail really from me _always_ has this .sig -- mail without it is forged spam]
     
    Henry S. Thompson, Jul 8, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carsten Brauer
    Replies:
    1
    Views:
    403
    Chris Smith
    Nov 24, 2004
  2. Wolfgang
    Replies:
    1
    Views:
    544
    Patrick TJ McPhee
    Apr 9, 2004
  3. Replies:
    5
    Views:
    1,774
    Peter Flynn
    Jul 3, 2006
  4. jblazi
    Replies:
    5
    Views:
    447
    jblazi
    Aug 16, 2004
  5. Phi!
    Replies:
    1
    Views:
    189
Loading...

Share This Page