You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Peter Anning <pe...@interati.co.uk> on 2000/06/30 15:06:08 UTC

BUG?

Cocoon 1.7.4

I have a custom producer that inserts xsl stylesheet and processing =
instructions into my xml before passing it to the xslt process for =
transform. These instuctions are ignored/removed if the xsl element =
attributes are in single quotes.

ie. this fails, Cocoon just delivers XML to the browser

<?xml-stylesheet
href='http://mantova:8080/data/guides/xslt/guideSectionPrevalence.xslt'
type='text/xsl'?>
<?cocoon-process type='xslt'?>

this works

<?xml-stylesheet
href="http://mantova:8080/data/guides/xslt/guideSectionPrevalence.xslt"
type="text/xsl"?>
<?cocoon-process type="xslt"?>

The single quotes used to work at 1.7

     Peter Anning


Re: BUG?

Posted by Niclas Hedhman <ni...@localbar.com>.
Hans Ulrich Niedermann wrote:

> As long as no one declares MIME types or uses path names that contain
> "'" or '"', this quick fix should work.

I disagree with "quick fixes". They tend to become "Permament Temproary solution".
When the problem is known, and (in this case) the solution is rather simple, one should give a proper cure.

Niclas


Re: BUG?

Posted by Hans Ulrich Niedermann <ni...@isd.uni-stuttgart.de>.
Hi Niclas!

Niclas Hedhman <ni...@localbar.com> writes:

> This won't work.
> You need to keep track of the match between " and ', since it is
> allowed to use the opposite character 
> inside a matching pair such as;
> 
> <department name="Children's department">

You're right when it concerns XML attributes. But I thought we were
talking only about processing instructions. All PI's used by Cocoon
I've seen so far look something like 

<?xml version="1.0" encoding="iso-8859-1"?>
<?cocoon-format type="text/html"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet type="text/xsl" href="../whereever/xyz.xsl" media='lynx'?>

As long as no one declares MIME types or uses path names that contain
"'" or '"', this quick fix should work. 

A quick "find -exec grep" seemed to confirm that the Utils.getPI*
functions are only used for PIs. But you're free to correct me.

In order to get a clean solution: What is the regexp class called?

Uli

> Hans Ulrich Niedermann wrote:

> > The following will probably work as long as nobody uses constructs
> > like '"' or "'". Otherwise it will be difficult without regexps.
> >
> > The code is untested as I'm too silly to get C1 & C2 working on the
> > same machine. But at least it compiles :-)
> >
> > Index: src/org/apache/cocoon/Utils.java
> > ===================================================================
> > RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/Utils.java,v
> > retrieving revision 1.16
> > diff -c -r1.16 Utils.java
> > *** src/org/apache/cocoon/Utils.java    2000/06/04 20:03:35     1.16
> > --- src/org/apache/cocoon/Utils.java    2000/07/02 18:43:05
> > ***************
> > *** 165,171 ****
> >       private static final void addPIPseudoAttributes(ProcessingInstruction pi, Hashtable attributes) {
> >           String data = pi.getData();
> >
> > !         Tokenizer st = new Tokenizer(data, "\"");
> >           try {
> >             while (st.hasMoreTokens()) {
> >                 String key   = st.nextToken();     // attribute name and '='
> > --- 165,171 ----
> >       private static final void addPIPseudoAttributes(ProcessingInstruction pi, Hashtable attributes) {
> >           String data = pi.getData();
> >
> > !         Tokenizer st = new Tokenizer(data, "\"'");
> >           try {
> >             while (st.hasMoreTokens()) {
> >                 String key   = st.nextToken();     // attribute name and '='

Re: BUG?

Posted by Niclas Hedhman <ni...@localbar.com>.
This won't work.
You need to keep track of the match between " and ', since it is allowed to use the opposite character
inside a matching pair such as;

<department name="Children's department">

Niclas

Hans Ulrich Niedermann wrote:

> Stefano Mazzocchi <st...@apache.org> writes:
>
> > Niclas Hedhman wrote:
>
> [ Attributes in Processing instructions ]
>
> > > clearly indicating that both " and ' should be allowed, as long as they
> > > are matching.
> >
> > Cool, so we've found a bug.... :)
> >
> > Anyway volunteers to fix it (it should be pretty trivial)
>
> The following will probably work as long as nobody uses constructs
> like '"' or "'". Otherwise it will be difficult without regexps.
>
> The code is untested as I'm too silly to get C1 & C2 working on the
> same machine. But at least it compiles :-)
>
> Index: src/org/apache/cocoon/Utils.java
> ===================================================================
> RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/Utils.java,v
> retrieving revision 1.16
> diff -c -r1.16 Utils.java
> *** src/org/apache/cocoon/Utils.java    2000/06/04 20:03:35     1.16
> --- src/org/apache/cocoon/Utils.java    2000/07/02 18:43:05
> ***************
> *** 165,171 ****
>       private static final void addPIPseudoAttributes(ProcessingInstruction pi, Hashtable attributes) {
>           String data = pi.getData();
>
> !         Tokenizer st = new Tokenizer(data, "\"");
>           try {
>             while (st.hasMoreTokens()) {
>                 String key   = st.nextToken();     // attribute name and '='
> --- 165,171 ----
>       private static final void addPIPseudoAttributes(ProcessingInstruction pi, Hashtable attributes) {
>           String data = pi.getData();
>
> !         Tokenizer st = new Tokenizer(data, "\"'");
>           try {
>             while (st.hasMoreTokens()) {
>                 String key   = st.nextToken();     // attribute name and '='
>
> And the following one fixes a missing heading in the C1 HTML docs.
>
> Index: skins/xml.apache.org/stylesheets/document2html.xsl
> ===================================================================
> RCS file: /home/cvspublic/xml-cocoon/skins/xml.apache.org/stylesheets/document2html.xsl,v
> retrieving revision 1.8
> diff -c -r1.8 document2html.xsl
> *** skins/xml.apache.org/stylesheets/document2html.xsl  2000/05/13 00:40:25     1.8
> --- skins/xml.apache.org/stylesheets/document2html.xsl  2000/07/02 18:43:03
> ***************
> *** 16,22 ****
>       <html>
>         <head>
>           <script language="JavaScript" type="text/javascript" src="resources/script.js"/>
> !         <title><xsl:value-of select="document/header/title"/></title>
>         </head>
>         <body text="#000000" link="#039acc" vlink="#0086b2" alink="#cc0000"
>               topmargin="4" leftmargin="4" marginwidth="4" marginheight="4"
> --- 16,22 ----
>       <html>
>         <head>
>           <script language="JavaScript" type="text/javascript" src="resources/script.js"/>
> !         <title><xsl:value-of select="(document|specification)/header/title"/></title>
>         </head>
>         <body text="#000000" link="#039acc" vlink="#0086b2" alink="#cc0000"
>               topmargin="4" leftmargin="4" marginwidth="4" marginheight="4"
>
> Have fun,
>
> Uli


Re: BUG?

Posted by Hans Ulrich Niedermann <ni...@isd.uni-stuttgart.de>.
Stefano Mazzocchi <st...@apache.org> writes:

> Niclas Hedhman wrote:

[ Attributes in Processing instructions ]

> > clearly indicating that both " and ' should be allowed, as long as they
> > are matching.
> 
> Cool, so we've found a bug.... :)
> 
> Anyway volunteers to fix it (it should be pretty trivial)

The following will probably work as long as nobody uses constructs
like '"' or "'". Otherwise it will be difficult without regexps. 

The code is untested as I'm too silly to get C1 & C2 working on the
same machine. But at least it compiles :-) 

Index: src/org/apache/cocoon/Utils.java
===================================================================
RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/Utils.java,v
retrieving revision 1.16
diff -c -r1.16 Utils.java
*** src/org/apache/cocoon/Utils.java	2000/06/04 20:03:35	1.16
--- src/org/apache/cocoon/Utils.java	2000/07/02 18:43:05
***************
*** 165,171 ****
      private static final void addPIPseudoAttributes(ProcessingInstruction pi, Hashtable attributes) {
          String data = pi.getData();
  
!         Tokenizer st = new Tokenizer(data, "\"");
          try {
            while (st.hasMoreTokens()) {
                String key   = st.nextToken();     // attribute name and '='
--- 165,171 ----
      private static final void addPIPseudoAttributes(ProcessingInstruction pi, Hashtable attributes) {
          String data = pi.getData();
  
!         Tokenizer st = new Tokenizer(data, "\"'");
          try {
            while (st.hasMoreTokens()) {
                String key   = st.nextToken();     // attribute name and '='

And the following one fixes a missing heading in the C1 HTML docs.

Index: skins/xml.apache.org/stylesheets/document2html.xsl
===================================================================
RCS file: /home/cvspublic/xml-cocoon/skins/xml.apache.org/stylesheets/document2html.xsl,v
retrieving revision 1.8
diff -c -r1.8 document2html.xsl
*** skins/xml.apache.org/stylesheets/document2html.xsl	2000/05/13 00:40:25	1.8
--- skins/xml.apache.org/stylesheets/document2html.xsl	2000/07/02 18:43:03
***************
*** 16,22 ****
      <html>
        <head>
          <script language="JavaScript" type="text/javascript" src="resources/script.js"/>
!         <title><xsl:value-of select="document/header/title"/></title>
        </head>
        <body text="#000000" link="#039acc" vlink="#0086b2" alink="#cc0000"
              topmargin="4" leftmargin="4" marginwidth="4" marginheight="4"
--- 16,22 ----
      <html>
        <head>
          <script language="JavaScript" type="text/javascript" src="resources/script.js"/>
!         <title><xsl:value-of select="(document|specification)/header/title"/></title>
        </head>
        <body text="#000000" link="#039acc" vlink="#0086b2" alink="#cc0000"
              topmargin="4" leftmargin="4" marginwidth="4" marginheight="4"

Have fun,

Uli

Re: BUG?

Posted by Stefano Mazzocchi <st...@apache.org>.
Niclas Hedhman wrote:
> 
> Peter Anning wrote:
> 
> > Cocoon 1.7.4
> >
> > I have a custom producer that inserts xsl stylesheet and processing =
> > instructions into my xml before passing it to the xslt process for =
> > transform. These instuctions are ignored/removed if the xsl element =
> > attributes are in single quotes.
> >
> > ie. this fails, Cocoon just delivers XML to the browser
> >
> > <?xml-stylesheet
> > href='http://mantova:8080/data/guides/xslt/guideSectionPrevalence.xslt'
> > type='text/xsl'?>
> > <?cocoon-process type='xslt'?>
> >
> > this works
> >
> > <?xml-stylesheet
> > href="http://mantova:8080/data/guides/xslt/guideSectionPrevalence.xslt"
> > type="text/xsl"?>
> > <?cocoon-process type="xslt"?>
> >
> > The single quotes used to work at 1.7
> >
> >      Peter Anning
> 
> XML spec says;
> 
> [10] AttValue ::= '"' ([^<&"] | Reference)* '"'
>                                  |  "'" ([^<&'] | Reference)* "'"
> 
> (Chapter 2.3)
> 
> clearly indicating that both " and ' should be allowed, as long as they
> are matching.

Cool, so we've found a bug.... :)

Anyway volunteers to fix it (it should be pretty trivial)

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------



Re: BUG?

Posted by Niclas Hedhman <ni...@localbar.com>.
Peter Anning wrote:

> Cocoon 1.7.4
>
> I have a custom producer that inserts xsl stylesheet and processing =
> instructions into my xml before passing it to the xslt process for =
> transform. These instuctions are ignored/removed if the xsl element =
> attributes are in single quotes.
>
> ie. this fails, Cocoon just delivers XML to the browser
>
> <?xml-stylesheet
> href='http://mantova:8080/data/guides/xslt/guideSectionPrevalence.xslt'
> type='text/xsl'?>
> <?cocoon-process type='xslt'?>
>
> this works
>
> <?xml-stylesheet
> href="http://mantova:8080/data/guides/xslt/guideSectionPrevalence.xslt"
> type="text/xsl"?>
> <?cocoon-process type="xslt"?>
>
> The single quotes used to work at 1.7
>
>      Peter Anning

XML spec says;

[10] AttValue ::= '"' ([^<&"] | Reference)* '"'
                                 |  "'" ([^<&'] | Reference)* "'"

(Chapter 2.3)

clearly indicating that both " and ' should be allowed, as long as they
are matching.

Niclas


Re: BUG?

Posted by Stefano Mazzocchi <st...@apache.org>.
Peter Anning wrote:
> 
> Cocoon 1.7.4
> 
> I have a custom producer that inserts xsl stylesheet and processing =
> instructions into my xml before passing it to the xslt process for =
> transform. These instuctions are ignored/removed if the xsl element =
> attributes are in single quotes.
> 
> ie. this fails, Cocoon just delivers XML to the browser
> 
> <?xml-stylesheet
> href='http://mantova:8080/data/guides/xslt/guideSectionPrevalence.xslt'
> type='text/xsl'?>
> <?cocoon-process type='xslt'?>
> 
> this works
> 
> <?xml-stylesheet
> href="http://mantova:8080/data/guides/xslt/guideSectionPrevalence.xslt"
> type="text/xsl"?>
> <?cocoon-process type="xslt"?>
> 
> The single quotes used to work at 1.7

I don't have the spec at hand... are both allowed?

-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Missed us in Orlando? Make it up with ApacheCON Europe in London!
------------------------- http://ApacheCon.Com ---------------------