You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Anna Afonchenko <an...@ubaccess.com> on 2003/05/13 12:28:42 UTC

Uncomment doctype declaration

Hi all.
I have an HTML document with doctype declaration commented like this:
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">-->

Now, when I output this file through cocoon pipeline, I want to apply a stylesheet that will uncomment the doctype declaration. I don't want to specify the doctype in serializer, because I don't know what doctype should the document have.

So I wrote a small xsl with identity transformation and template for uncommenting the doctype:

<xsl:template match="node()[self::comment()][contains(.,'DOCTYPE')]">
    <xsl:value-of select="."/>
</xsl:template>

But when I run this through Cocoon, I get the following error message:

message javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Invalid processing instruction name (saxon:warning)
description org.apache.cocoon.ProcessingException: Could not read resource file:/c:/my documents/work/applications/ub/yadsarahd5.html: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Invalid processing instruction name (saxon:warning)

I tried to disable output escaping:
<xsl:value-of disable-output-escaping="yes" select="."/>

but then all I get in teh output is empty document with source:
<?javax.xml.transform.disable-output-escaping ><?javax.xml.transform.disable-output-escaping ><?javax.xml.transform.disable-output-escaping ><?javax.xml.transform.disable-output-escaping >

Is there a way to uncomment a doctype declaration so it will be valid doctype for a document?
Once again, I don't want to use the doctype declaration of the serializer, I want the html page itself to contain the appropriate doctype within a comment.

Thank you very much for help.

Anna

Re: Uncomment doctype declaration

Posted by Charles Yates <ce...@stanford.edu>.
Yes, I cut and pasted your stylesheet and used the following xml and it 
worked in cocoon 2.1-M2 no problem.  Try using xalan instead of saxon.

<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">-->
<test/>

output from cocoon:

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

Anna Afonchenko wrote:

>Does this work for you in Cocoon?
>Because this stylesheet works if I apply it in XMLSpy or through batch file,
>but doesn't work through Cocoon pipeline.
>Maybe Cocoon has some problems with disable-output-escaping?
>This is my full stylesheet that works using batch file but doesn't work
>using Cocoon:
><?xml version="1.0" encoding="UTF-8"?>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
><xsl:output method="xml"/>
><xsl:template match="node()|@*">
>  <xsl:copy>
>   <xsl:apply-templates select="node()|@*"/>
>  </xsl:copy>
> </xsl:template>
>
><xsl:template match="node()[self::comment()][contains(.,'DOCTYPE')]">
>   <xsl:value-of disable-output-escaping="yes" select="."/>
> </xsl:template>
></xsl:stylesheet>
>
>Please, can somebody explain me why this doesn't work in Cocoon?
>
>Thank you very much for help.
>Anna
>
>----- Original Message -----
>From: "Charles Yates" <ce...@stanford.edu>
>To: <co...@xml.apache.org>
>Sent: Tuesday, May 13, 2003 11:19 PM
>Subject: Re: Uncomment doctype declaration
>
>
>Maybe you are not calling the comment() nodes from the root.  This works
>for me:
>
><xsl:template match="/">
><xsl:apply-templates select="*|comment()"/>
></xsl:template>
>
><xsl:template match="comment()[contains(.,'DOCTYPE')">
><xsl:value-of select="." disable-output-escaping="yes"/>
></xsl:template>
>
>Anna Afonchenko wrote:
>
>  
>
>>Hi all.
>>I have an HTML document with doctype declaration commented like this:
>><!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">-->
>>
>>Now, when I output this file through cocoon pipeline, I want to apply
>>a stylesheet that will uncomment the doctype declaration. I don't want
>>to specify the doctype in serializer, because I don't know what
>>doctype should the document have.
>>
>>So I wrote a small xsl with identity transformation and template for
>>uncommenting the doctype:
>>
>><xsl:template match="node()[self::comment()][contains(.,'DOCTYPE')]">
>>    <xsl:value-of select="."/>
>></xsl:template>
>>
>>But when I run this through Cocoon, I get the following error message:
>>
>>*message* _javax.xml.transform.TransformerException:
>>javax.xml.transform.TransformerException: org.xml.sax.SAXException:
>>Invalid processing instruction name (saxon:warning)_
>>*description* _org.apache.cocoon.ProcessingException: Could not read
>>resource file:/c:/my documents/work/applications/ub/yadsarahd5.html:
>>javax.xml.transform.TransformerException:
>>javax.xml.transform.TransformerException:
>>javax.xml.transform.TransformerException: org.xml.sax.SAXException:
>>Invalid processing instruction name (saxon:warning)_
>>
>>I tried to disable output escaping:
>><xsl:value-of disable-output-escaping="yes" select="."/>
>>
>>but then all I get in teh output is empty document with source:
>><?javax.xml.transform.disable-output-escaping
>>    
>>
>>><?javax.xml.transform.disable-output-escaping
>>><?javax.xml.transform.disable-output-escaping
>>><?javax.xml.transform.disable-output-escaping >
>>>      
>>>
>>Is there a way to uncomment a doctype declaration so it will be valid
>>doctype for a document?
>>Once again, I don't want to use the doctype declaration of the
>>serializer, I want the html page itself to contain the appropriate
>>doctype within a comment.
>>
>>Thank you very much for help.
>>
>>Anna
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Uncomment doctype declaration

Posted by Anna Afonchenko <an...@ubaccess.com>.
Does this work for you in Cocoon?
Because this stylesheet works if I apply it in XMLSpy or through batch file,
but doesn't work through Cocoon pipeline.
Maybe Cocoon has some problems with disable-output-escaping?
This is my full stylesheet that works using batch file but doesn't work
using Cocoon:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="node()|@*">
  <xsl:copy>
   <xsl:apply-templates select="node()|@*"/>
  </xsl:copy>
 </xsl:template>

<xsl:template match="node()[self::comment()][contains(.,'DOCTYPE')]">
   <xsl:value-of disable-output-escaping="yes" select="."/>
 </xsl:template>
</xsl:stylesheet>

Please, can somebody explain me why this doesn't work in Cocoon?

Thank you very much for help.
Anna

----- Original Message -----
From: "Charles Yates" <ce...@stanford.edu>
To: <co...@xml.apache.org>
Sent: Tuesday, May 13, 2003 11:19 PM
Subject: Re: Uncomment doctype declaration


Maybe you are not calling the comment() nodes from the root.  This works
for me:

<xsl:template match="/">
<xsl:apply-templates select="*|comment()"/>
</xsl:template>

<xsl:template match="comment()[contains(.,'DOCTYPE')">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>

Anna Afonchenko wrote:

> Hi all.
> I have an HTML document with doctype declaration commented like this:
> <!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">-->
>
> Now, when I output this file through cocoon pipeline, I want to apply
> a stylesheet that will uncomment the doctype declaration. I don't want
> to specify the doctype in serializer, because I don't know what
> doctype should the document have.
>
> So I wrote a small xsl with identity transformation and template for
> uncommenting the doctype:
>
> <xsl:template match="node()[self::comment()][contains(.,'DOCTYPE')]">
>     <xsl:value-of select="."/>
> </xsl:template>
>
> But when I run this through Cocoon, I get the following error message:
>
> *message* _javax.xml.transform.TransformerException:
> javax.xml.transform.TransformerException: org.xml.sax.SAXException:
> Invalid processing instruction name (saxon:warning)_
> *description* _org.apache.cocoon.ProcessingException: Could not read
> resource file:/c:/my documents/work/applications/ub/yadsarahd5.html:
> javax.xml.transform.TransformerException:
> javax.xml.transform.TransformerException:
> javax.xml.transform.TransformerException: org.xml.sax.SAXException:
> Invalid processing instruction name (saxon:warning)_
>
> I tried to disable output escaping:
> <xsl:value-of disable-output-escaping="yes" select="."/>
>
> but then all I get in teh output is empty document with source:
> <?javax.xml.transform.disable-output-escaping
> ><?javax.xml.transform.disable-output-escaping
> ><?javax.xml.transform.disable-output-escaping
> ><?javax.xml.transform.disable-output-escaping >
>
> Is there a way to uncomment a doctype declaration so it will be valid
> doctype for a document?
> Once again, I don't want to use the doctype declaration of the
> serializer, I want the html page itself to contain the appropriate
> doctype within a comment.
>
> Thank you very much for help.
>
> Anna



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Re: Uncomment doctype declaration

Posted by Charles Yates <ce...@stanford.edu>.
Maybe you are not calling the comment() nodes from the root.  This works 
for me:

<xsl:template match="/">
<xsl:apply-templates select="*|comment()"/>
</xsl:template>

<xsl:template match="comment()[contains(.,'DOCTYPE')">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>

Anna Afonchenko wrote:

> Hi all.
> I have an HTML document with doctype declaration commented like this:
> <!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">-->
>  
> Now, when I output this file through cocoon pipeline, I want to apply 
> a stylesheet that will uncomment the doctype declaration. I don't want 
> to specify the doctype in serializer, because I don't know what 
> doctype should the document have.
>  
> So I wrote a small xsl with identity transformation and template for 
> uncommenting the doctype:
>  
> <xsl:template match="node()[self::comment()][contains(.,'DOCTYPE')]">
>     <xsl:value-of select="."/>
> </xsl:template>
>  
> But when I run this through Cocoon, I get the following error message:
>  
> *message* _javax.xml.transform.TransformerException: 
> javax.xml.transform.TransformerException: org.xml.sax.SAXException: 
> Invalid processing instruction name (saxon:warning)_
> *description* _org.apache.cocoon.ProcessingException: Could not read 
> resource file:/c:/my documents/work/applications/ub/yadsarahd5.html: 
> javax.xml.transform.TransformerException: 
> javax.xml.transform.TransformerException: 
> javax.xml.transform.TransformerException: org.xml.sax.SAXException: 
> Invalid processing instruction name (saxon:warning)_
>  
> I tried to disable output escaping:
> <xsl:value-of disable-output-escaping="yes" select="."/>
>  
> but then all I get in teh output is empty document with source:
> <?javax.xml.transform.disable-output-escaping 
> ><?javax.xml.transform.disable-output-escaping 
> ><?javax.xml.transform.disable-output-escaping 
> ><?javax.xml.transform.disable-output-escaping >
>  
> Is there a way to uncomment a doctype declaration so it will be valid 
> doctype for a document?
> Once again, I don't want to use the doctype declaration of the 
> serializer, I want the html page itself to contain the appropriate 
> doctype within a comment.
>  
> Thank you very much for help.
>  
> Anna



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org