cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anna Afonchenko" <a...@ubaccess.com>
Subject Re: XPath problems in Cocoon?
Date Thu, 20 Feb 2003 12:39:06 GMT
Even if the white spaces are supressed, the algorythm will stay right, because algorythm should
check
all a tags that are followed by another a tag, and the only node between them MAY (not MUST)
be white-space only text node.
Whatever the generator will do to the input file, it cannot possibly insert some non-space
characters
between two a tags that in the input file were separated just by white-space, so the algorythm
should
still give the right answer. But since I indeed do not know how the input document will be
rendered after
going through generator, and moreover, through JTidy, I cannot rely on the fact that threre
will be no whitespaces
between two adjacent anchor tags, thus, I cannot just say in my XPath "choose all a tags for
which the first following node is also an a tag", because for the case with not suppressed
whitespaces, it will return wrong answers.
There are some parsers that ingnore white space only nodes, so for them I wouldn't need to
bother, but I use Saxon parser, and it
considers white-space as a node, and I already encountered few cases where it mattered.
Conclusion: I must check for presence of white spaces and whether they are present or not,
return correct answer,
all a tags that have adjacent a tag, i.e. first following tag that is not white space is a
tag.
Sorry, I know that this is not too much related to Cocoon, but this really frustrates me -
WHAT should be the right XPath for
this not-so-hard case to work in Cocoon??!
Maybe somebody can give some idea?

I really appreciate all your help.

Thank you very much for answering.

Anna
  ----- Original Message ----- 
  From: Laurent Comte 
  To: cocoon-users@xml.apache.org 
  Sent: Thursday, February 20, 2003 2:18 PM
  Subject: RE: XPath problems in Cocoon?


  Not the answer but ...

  Are you obliged to base your algorithm on the presence of whitespaces ?

  If your html file is like :
  <a href="one.html">One</a>  <a href="two.html">Two</a>

  , I won't bet a cent on how it will be rendered after the generator process ...

  Perhaps they will be suppressed, or what else ?  ...

  And perhaps I didn't understood what you want to get exactly ...

  Laurent.
    -----Message d'origine-----
    De : Anna Afonchenko [mailto:anna@ubaccess.com]
    Envoyé : jeudi 20 février 2003 12:57
    À : cocoon-users
    Objet : Re: XPath problems in Cocoon?



     
    I tried it with XPathVisualizer tool, and it gives right result.
    But when I tried to run the stylesheet through the batch file using Saxon, I also
    got empty result.
    So I am really confused.
    Maybe somebody can suggest another XPath to accomplish this?
    I want to choose all a tags for which the first following tag that is not a white-space
only text
    is also a tag, e.g. when there are adjacent a tags with no separate characters between
them.
    This seems to be not too complex XPath, and the XPath that I constructed:
    //a[name(following-sibling::node()[1][not(self::text() and normalize-space())])='a']

    seems to be rather intuitive, so I am really confused why it doesn't work.
    Moreover, why it DOES work in XMLSpy/XPathVisualizer and DOESN"T work with Saxon/Cocoon.

    I am really confused and will really appreciate any help with this issue.

    Thank you very much for help.

    Anna
      ----- Original Message ----- 
      From: Derek Hohls 
      To: cocoon-users@xml.apache.org 
      Sent: Thursday, February 20, 2003 1:27 PM
      Subject: Re: XPath problems in Cocoon?


      Hmm - I tried this same transform using Jame Clarke's
      XT program (old, but normally robust) and I got the 
      same result - 
       
      <?xml version="1.0" encoding="utf-8" ?> 
        <root />

      I am not an XSLT guru - are you sure the syntax is not
      specific to XML spy??  Have you tried with some other
      XSLT engine?

      Derek

      >>> anna@ubaccess.com 20/02/2003 01:04:47 >>>

      Derek

      I don't get any error message, at least not in WEB-IN/logs/error.log
      I get an xml document in the browser:
      <?xml version="1.0" encoding="utf-8" ?> 
        <root /> 

      i.e., the stylesheet was applied successfully, it just didn't match anything.
      Maybe my XPath expression is wrong, but then how comes it works in XMLSpy?

      Thanks for answering
      Anna
        ----- Original Message ----- 
        From: Derek Hohls 
        To: cocoon-users@xml.apache.org 
        Sent: Thursday, February 20, 2003 12:51 PM
        Subject: Re: XPath problems in Cocoon?


        Anna

        What type of error message do you get in the log files?

        >>> anna@ubaccess.com 20/02/2003 12:40:10 >>>

        Hi all. I am not sure that this message is related to Cocoon, so I apologize,
        if this is not appropriate here.

        I have a very simple html - test.html:
        <html>
        <head>
        <title>Test anchors</title>
        </head>
        <body>
        <p>test anchors</p>
        <a href="one.html">One</a>  <a href="two.html">Two</a>
        <div>separator</div>
        <a href="one.html">One1</a>
        <br />
        <a href="two.html">Two1</a>
        <div>separator</div>
        <a href="one.html">One2</a>
        some text
        <a href="two.html">Two2</a>
        </body>
        </html>

        I want to choose the 'a' nodes for which first following node that is not a white-space
only node is 'a' node. E.g. in the html above only the first 'a' node should be picked up.
        I wrote a very simple xsl - test.xsl:
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
        <root>
        <xsl:for-each select="//a[name(following-sibling::node()[1][not(self::text() and
normalize-space())])='a']">
        <xsl:value-of select="."/>
        </xsl:for-each>
        </root>
        </xsl:template>
        </xsl:stylesheet>

        When I apply this stylesheet on my test.html using XMLSpy's XSL Transformation Tool,
I get this xml:
        <root>One</root>, e.g. it chose correctly the first a node.
        But when I apply this stylesheet using Cocoon, I get empty <root/> as a result,
e.g. in Cocoon nothing is chosen.
        Here is my pipeline:
        <map:match pattern="testAnchors">
        <map:generate src="ub/testing/test.html" type="html"/>
        <map:transform type="xslt-saxon" src="ub/testing/test.xsl"/>
        <map:serialize type="xml"/>
        </map:match>

        Can somebody explain me what is wrong with my stylesheet and why doesn't it work using
Cocoon?

        Thank you very much for help and sorry if this is not too much related.

        Best regards,

        Anna

        -- 
        This message has been scanned for viruses and dangerous content by 
        MailScanner, and is believed to be clean. 

        "The CSIR exercises no editorial control over E-mail messages and/or 
        attachments thereto/links referred to therein originating in the 
        organisation and the views in this message/attachments thereto are 
        therefore not necessarily those of the CSIR and/or its employees. 
        The sender of this e-mail is, moreover, in terms of the CSIR's Conditions 
        of Service, subject to compliance with the CSIR's internal E-mail and 
        Internet Policy." 

      -- 
      This message has been scanned for viruses and dangerous content by 
      MailScanner, and is believed to be clean. 

      "The CSIR exercises no editorial control over E-mail messages and/or 
      attachments thereto/links referred to therein originating in the 
      organisation and the views in this message/attachments thereto are 
      therefore not necessarily those of the CSIR and/or its employees. 
      The sender of this e-mail is, moreover, in terms of the CSIR's Conditions 
      of Service, subject to compliance with the CSIR's internal E-mail and 
      Internet Policy." 

Mime
View raw message