[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XML source with DOCTYPE declaration

Subject: Re: XML source with DOCTYPE declaration
From: Zeljko Rajic <zeljko.rajic@xxxxxxxxxx>
Date: Fri, 20 Apr 2001 14:31:46 +0200
xhtml basic templates
Hi Jeni,

> That's right - it adds the attribute that is the XHTML namespace
> declaration to the document element (html).  Actually, given the other
> entities I guess that you'll find something like:
> 
> <!ATTLIST %html.qname
>    %XHTML.xmlns.attrib;>

Once more you are right. :)  I found the following statement:

<!ATTLIST %html.qname;
      %XHTML.xmlns.attrib;
      %XHTML.version.attrib;
      %I18n.attrib; >

But then I do not understand why it is necessary to add the namespace to
every (X)HTML element/tag as it is being done?

> but I'm just guessing here - the DTD for XHTML I have doesn't seem to
> be as complex as the one you do.

To be precise I am using the DTD from XHTML Basic 1.0. It's DOCTYPE
declaration looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">

> 
> > So does this mean there is no way to use one stylesheet for both
> > kind of XHTML files - with and without a DOCTYPE statement including
> > the XHTML DTD ???
> 
> Sort of.  If you have an XHTML document that *doesn't* have the
> DOCTYPE statement, then you need to explicitly give the namespace for
> the XHTML rather than letting it be brought in from the DTD.  So it
> should look like:
> 
> <html xmlns="http://www.w3.org/1999/xhtml">
>    ...
> </html>

Well, that would be an solution if I would have the possible to change
the content of the source XML files, which I do not have.   :(

> You could do that or:
> 
> <xsl:template match="/html | /html:html">
>    <xsl:text>html element found !!!</xsl:text>
> </xsl:template>
> 
> Or even:
> 
> <xsl:template match="/*[local-name() = 'html']">
>    <xsl:text>html element found !!!</xsl:text>
> </xsl:template>

Hmmmm... that might be a solution, but it also would make the
stylesheet(s) kind of 'unreadable' and debugging/maintenance activies
much more difficult !!  :(

> 
> But it's better to use the XHTML namespace for the elements that are
> part of XHTML, and it's obviously easier to write a stylesheet that
> uses that namespace that one that covers both.  If you have both kinds
> of documents, then you could do some preprocessing to move the
> elements into that namespace.  If you have a stylesheet that just
> looks has the following templates in it:
> 
> <xsl:template match="*">
>    <xsl:element name="{local-name()}"
>                 namespace="http://www.w3.org/1999/xhtml">
>       <xsl:copy-of select="@*" />
>       <xsl:apply-templates />
>    </xsl:element>
> </xsl:template>

After some testing this seems to be the best solution so far!!  :)


> > Ok, I think I understand. Another unwanted thing I noticed with the
> > <xsl:copy-of> was that all XML comments from the DTD are being
> > printed.
> 
> >From the DTD?!?  That sounds very strange.  Could you give a sample
> that shows that happening?  Which processor are you using?

Well, when I place a <xsl:cop-of/> at the template matching the root
element ("/"), I receive the following output:

<?xml version="1.0" encoding="UTF-8"?>
<!--
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basi
c10.dtd">
-->
<!-- XHTML Basic 1.0 DTD 
...................................................... -->
<!-- file: xhtml-basic10.dtd -->
<!-- XHTML Basic 1.0 DTD

     This is XHTML Basic, a proper subset of XHTML.

     The Extensible HyperText Markup Language (XHTML)
     Copyright 1998-2000 World Wide Web Consortium
        (Massachusetts Institute of Technology, Institut National de
         Recherche en Informatique et en Automatique, Keio University).
         All Rights Reserved.


............  A LOT OF MORE COMMENTS HAVE BEEN CUT HERE ...............


<!-- end of html.element -->
<!-- version attribute value defined in driver
-->
<!-- see the Qualified Names module for information
     on how to extend XHTML using XML namespaces
-->
<!--
                moved from the ATTLIST down there.
      %XHTML.xmlns.attrib;
-->
<!-- end of html.attlist -->
<!-- end of xhtml-struct-1.mod -->
<!-- end of XHTML Basic 1.0 DTD 
........................................... -->


I'm using Xalan J 2.0.0 as XSLT processor.
Any hints how to deactive this??


One further question concerning my problem:
Is there a possibilty to check in the XSLT stylesheet which or how many
namespaces are declare/used in the XML file which is being transformed?


Regards,
Zeljko

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.