You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Jose Correia <jo...@exinet.co.za> on 2000/07/28 08:32:38 UTC

how to include a DOCTYPE on my xsl file

Hi all

I'm trying to do the following:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" encoding="US-ASCII"/>

<xsl:template match ="assessment">
<!DOCTYPE assessment PUBLIC "-//EDUFLEX.COM//DTD ASSESSMENT 1.0//EN"
"readerAssessment.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <title><xsl:value-of select ="@name"/> </title>

</head>
</html>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

Everything works except for line 6 (DOCTYPE). The processor complains saying:
"org.apache.xalan.xslt.XSLProcessorException: The content of elements must
consist of well-formed character data or markup."

Any ideas on how to include that DOCTYPe to the ouput file. I tried wrapping it
in a <xsl:text> but to no avail (same error).

Thanks
Jose




Re: how to include a DOCTYPE on my xsl file

Posted by Juergen Hermann <jh...@webde-ag.de>.
On Fri, 28 Jul 2000 08:32:38 +0200, Jose Correia wrote:

><xsl:output method="xml" encoding="US-ASCII"/>

DOCTYPE belongs here, see the spec...


Ciao, Jürgen

--
Jürgen Hermann, Developer (jhe@webde-ag.de)
WEB.DE AG, http://webde-ag.de/



Re: how to include a DOCTYPE on my xsl file

Posted by Norman Walsh <nd...@nwalsh.com>.
/ jose@exinet.co.za (Jose Correia) was heard to say:
| Thanks Ed, but there must surely be a way to specify the name to something else
| other than 'html' ?? Scott?

The DOCTYPE name must, by definition, be the name of the root element
of your result tree. If that element is "assessment", that's what will
go in the DOCTYPE line. You have no direct control over it because there's
only one possible right name for any given result tree.

Handed

<?xml version='1.0'?>
<foo/>

This stylesheet:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version='1.0'>

<xsl:output method="xml" encoding="US-ASCII"
doctype-system="readerAssessment.dtd"
doctype-public="-//EDUFLEX.COM//DTD ASSESSMENT 1.0//EN"/>

<xsl:template match="foo">
  <assessment/>
</xsl:template>

</xsl:stylesheet>

produces:

hermes:~$ xalan test.xml test.xsl
xalan -IN test.xml -XSL test.xsl
Loading catalog: /share/doctypes/catalog
========= Parsing file:/home/ndw/test.xsl ==========
Parse of file:/home/ndw/test.xsl took 167 milliseconds
========= Parsing file:/home/ndw/test.xml ==========
Parse of file:/home/ndw/test.xml took 67 milliseconds
=============================
Transforming...
<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE assessment PUBLIC "-//EDUFLEX.COM//DTD ASSESSMENT 1.0//EN" "readerAssessment.dtd">
<assessment/>transform took 26 milliseconds
XSLProcessor: done

                                        Be seeing you,
                                          norm

-- 
Norman.Walsh@East.Sun.COM | Why in our youth does the life we still
XML Technology Center     | have before us look so immeasurably long?
Sun Microsystems, Inc.    | Because we have to find room for the
                          | boundless hopes with which we cram
                          | it.--Schopenhauer

Re: how to include a DOCTYPE on my xsl file

Posted by Jose Correia <jo...@exinet.co.za>.
Sorry Ed I ended up confusing you. For this example I don't need the DOCType to be
something else. I was just thinking what if the root element was different but
you've pointed me to the part of the spec where it answers that  for me ( I was
actually a tad lazy there) so thanks for your time.

Regards
Jose Correia

Ed Staub wrote:

> José Correia wrote:
> >Thanks Ed, but there must surely be a way to specify the name to something
> else
> >other than 'html' ?? Scott?
>
> >From the spec (http://www.w3.org/TR/xslt#section-HTML-Output-Method):
>
>         "If the doctype-public or doctype-system attributes are specified,
>         then the html output method should output a document type declaration
>         immediately before the first element.
>
>         The name following <!DOCTYPE should be HTML or html."
>
> If your output-encoding is XML (not HTML), then from
> http://www.w3.org/TR/xslt#section-XML-Output-Method:
>
>         "The name following <!DOCTYPE should be the name of the first element."
>
> Also, the XML spec states
> (http://www.w3.org/TR/1998/REC-xml-19980210#sec-prolog-dtd):
>         "Validity Constraint: Root Element Type
>         The Name in the document type declaration must match the element type of
> the root element. "
> So I'm not sure why you would want the name to be anything other than HTML;
> it's invalid XML.
>
> The relevant code is at
> org.apache.xalan.xpath.xml.FormatterToHTML.startDocument():
>         accum("<!DOCTYPE HTML");
> So there aren't any proprietary Xalan escape hatches.
>
> At the risk of exposing my lack of imagination... why do you need this?
>
> -Ed
>
> --------------
>
> Ed Staub wrote:
>
> > You want something like:
> >
> > <xsl:output method="xml" encoding="US-ASCII"
> > doctype-system="readerAssessment.dtd"
> > doctype-public="-//EDUFLEX.COM//DTD ASSESSMENT 1.0//EN"/>
> >
> > The doctype name must be 'html'; you have no control over it.
> > See http://www.w3.org/TR/xslt#section-HTML-Output-Method (near the bottom)
> > for the full specification.
> >
> > -Ed Staub
> >
> > -----Original Message-----
> > From: Jose Correia [mailto:jose@exinet.co.za]
> > Sent: Friday, July 28, 2000 2:33 AM
> > To: xalan-dev@xml.apache.org
> > Subject: how to include a DOCTYPE on my xsl file
> >
> > Hi all
> >
> > I'm trying to do the following:
> >
> > <?xml version="1.0"?>
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > version="1.0">
> > <xsl:output method="xml" encoding="US-ASCII"/>
> >
> > <xsl:template match ="assessment">
> > <!DOCTYPE assessment PUBLIC "-//EDUFLEX.COM//DTD ASSESSMENT 1.0//EN"
> > "readerAssessment.dtd">
> > <html xmlns="http://www.w3.org/1999/xhtml">
> > <head>
> >  <title><xsl:value-of select ="@name"/> </title>
> >
> > </head>
> > </html>
> > <xsl:apply-templates/>
> > </xsl:template>
> > </xsl:stylesheet>
> >
> > Everything works except for line 6 (DOCTYPE). The processor complains
> > saying:
> > "org.apache.xalan.xslt.XSLProcessorException: The content of elements must
> > consist of well-formed character data or markup."
> >
> > Any ideas on how to include that DOCTYPe to the ouput file. I tried
> wrapping
> > it
> > in a <xsl:text> but to no avail (same error).
> >
> > Thanks
> > Jose

--

                \=/,         _-===-_-===-_-===-_-===-_-==-_
                |  @___oo  (                               )_
      /\  /\   / (___,,,}_--=                                )
     ) /^\) ^\/ _)        =_"Positive thinking - a great way  )
     )   /^\/   _)         (_        to face life"             )
     )   _ /  / _)          (        Jose Correia            )
 /\  )/\/ ||  | )_)          (_    jose@exinet.co.za        )
<  >      |(,,) )__)           (   jcorreia@global.co.za    )
 ||      /    \)___)\           (_                        _)
 | \____(      )___) )___          -==-_______-=====-___==
  \______(_______;;; __;;;



RE: how to include a DOCTYPE on my xsl file

Posted by Ed Staub <es...@mediaone.net>.
José Correia wrote:
>Thanks Ed, but there must surely be a way to specify the name to something
else
>other than 'html' ?? Scott?

Re: how to include a DOCTYPE on my xsl file

Posted by Jose Correia <jo...@exinet.co.za>.
Thanks Ed, but there must surely be a way to specify the name to something else
other than 'html' ?? Scott?

Regards
Jose

Ed Staub wrote:

> You want something like:
>
> <xsl:output method="xml" encoding="US-ASCII"
> doctype-system="readerAssessment.dtd"
> doctype-public="-//EDUFLEX.COM//DTD ASSESSMENT 1.0//EN"/>
>
> The doctype name must be 'html'; you have no control over it.
> See http://www.w3.org/TR/xslt#section-HTML-Output-Method (near the bottom)
> for the full specification.
>
> -Ed Staub
>
> -----Original Message-----
> From: Jose Correia [mailto:jose@exinet.co.za]
> Sent: Friday, July 28, 2000 2:33 AM
> To: xalan-dev@xml.apache.org
> Subject: how to include a DOCTYPE on my xsl file
>
> Hi all
>
> I'm trying to do the following:
>
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="xml" encoding="US-ASCII"/>
>
> <xsl:template match ="assessment">
> <!DOCTYPE assessment PUBLIC "-//EDUFLEX.COM//DTD ASSESSMENT 1.0//EN"
> "readerAssessment.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
>  <title><xsl:value-of select ="@name"/> </title>
>
> </head>
> </html>
> <xsl:apply-templates/>
> </xsl:template>
> </xsl:stylesheet>
>
> Everything works except for line 6 (DOCTYPE). The processor complains
> saying:
> "org.apache.xalan.xslt.XSLProcessorException: The content of elements must
> consist of well-formed character data or markup."
>
> Any ideas on how to include that DOCTYPe to the ouput file. I tried wrapping
> it
> in a <xsl:text> but to no avail (same error).
>
> Thanks
> Jose

--

                \=/,         _-===-_-===-_-===-_-===-_-==-_
                |  @___oo  (                               )_
      /\  /\   / (___,,,}_--=                                )
     ) /^\) ^\/ _)        =_"Positive thinking - a great way  )
     )   /^\/   _)         (_        to face life"             )
     )   _ /  / _)          (        Jose Correia            )
 /\  )/\/ ||  | )_)          (_    jose@exinet.co.za        )
<  >      |(,,) )__)           (   jcorreia@global.co.za    )
 ||      /    \)___)\           (_                        _)
 | \____(      )___) )___          -==-_______-=====-___==
  \______(_______;;; __;;;



RE: how to include a DOCTYPE on my xsl file

Posted by Ed Staub <es...@mediaone.net>.
You want something like:

<xsl:output method="xml" encoding="US-ASCII"
doctype-system="readerAssessment.dtd"
doctype-public="-//EDUFLEX.COM//DTD ASSESSMENT 1.0//EN"/>

The doctype name must be 'html'; you have no control over it.
See http://www.w3.org/TR/xslt#section-HTML-Output-Method (near the bottom)
for the full specification.

-Ed Staub

-----Original Message-----
From: Jose Correia [mailto:jose@exinet.co.za]
Sent: Friday, July 28, 2000 2:33 AM
To: xalan-dev@xml.apache.org
Subject: how to include a DOCTYPE on my xsl file


Hi all

I'm trying to do the following:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" encoding="US-ASCII"/>

<xsl:template match ="assessment">
<!DOCTYPE assessment PUBLIC "-//EDUFLEX.COM//DTD ASSESSMENT 1.0//EN"
"readerAssessment.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <title><xsl:value-of select ="@name"/> </title>

</head>
</html>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

Everything works except for line 6 (DOCTYPE). The processor complains
saying:
"org.apache.xalan.xslt.XSLProcessorException: The content of elements must
consist of well-formed character data or markup."

Any ideas on how to include that DOCTYPe to the ouput file. I tried wrapping
it
in a <xsl:text> but to no avail (same error).

Thanks
Jose