This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Transforming XHTML possible?


Hi Dwight,

At 04:20 PM 4/13/01, you wrote:

>Is it possible to transform XHTML ?

If that's what it is, yup.

>I have created what I think is a most basic example. The XHTML is by the
>standard. The style sheet should merely "copy" the XHTML from input to
>output. It looks to me like the xPath queries are not working. I'm using
>MSXML3. What am I missing ?  Why doesn't this simple example work ?  Are my
>copy templates missing something ?
>
>Dwight Funk
>POWERWAY, Inc.

I see two problems here.

One is that, if this is really your input:

>---------------TEST.XML---------------------------------------------------
><?xml version="1.0" encoding="UTF-8"?>
>
><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
>
>Test
>---------------TEST.XML---------------------------------------------------

you'll have problems because it shouldn't parse. One requirement for 
well-formed XML is that the instance have a root element node (often called 
a 'document element' in XSLT to avoid confusing it with the root node of 
the XPath tree, which is its parent). That is,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<test>Test</test>

would be well-formed (albeit not valid to XHTML). What you have would be a 
well-formed 'external parsed entity' except those critters can't have 
DOCTYPE declarations.

So your parser should be throwing out your input file as not well-formed.

If it isn't, you get the second problem. Your stylesheet:

>---------------TEST.XSL---------------------------------------------------
><?xml version="1.0" encoding="UTF-8"?>
>
><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>version="1.0">
>
>         <xsl:output method="xml" encoding="UTF-8"/>
>
>         <!-- Match the root node -->
>         <xsl:template match="/">
>                 <xsl:apply-templates select="*"/>
>         </xsl:template>
>...

This root node template selects element children of the root (select="*"), 
but your document has no element children of the root (just a text node 
containing the string 'Test').

Try it with this input:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html><body>Test</body></html>

and see what happens.

Good luck,
Wendell

======================================================================
Wendell Piez                            mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]