You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Mark Dzmura <md...@digital-mission.com> on 2000/04/05 01:51:32 UTC

error testing attribute existence with for-each

When I try to process the following XSLT, trying to test for the existence of an attribute called
"selected" in the current node:

    <xsl:for-each selected="./@selected">

I get the following error from cocoon.  It does not matter whether the attribute exists
or not - the error is always generated.  Apparently XSLT is reporting an error, but there
is no descriptive text accompanying it...

Any ideas?

Thanks,
Mark Dzmura

----------------------

Cocoon 1.7

                                                            Error found handling the request.

                       org.apache.xalan.xslt.XSLProcessorException:
                               at org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1650)
                               at org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1559)
                               at org.apache.xalan.xslt.ElemForEach.(ElemForEach.java:101)
                               at org.apache.xalan.xslt.StylesheetHandler.startElement(StylesheetHandler.java:684)
                               at org.apache.xalan.xpath.xml.TreeWalker.startNode(TreeWalker.java:195)
                               at org.apache.xalan.xpath.xml.TreeWalker.traverse(TreeWalker.java:98)
                               at org.apache.xalan.xslt.XSLTEngineImpl.processStylesheet(XSLTEngineImpl.java:682)
                               at org.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java:531)
                               at org.apache.cocoon.transformer.XalanTransformer.transform(XalanTransformer.java:94)
                               at org.apache.cocoon.processor.xslt.XSLTProcessor.process(XSLTProcessor.java:103)
                               at org.apache.cocoon.Engine.handle(Engine.java:283)
                               at org.apache.cocoon.Cocoon.service(Cocoon.java:145)
                               at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
                               at org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)
                               at org.apache.jserv.JServConnection.run(JServConnection.java:188)
                               at java.lang.Thread.run(Thread.java:479)


Re: error testing attribute existence with for-each

Posted by Mark Dzmura <md...@digital-mission.com>.
Ed:

Thanks for the tip.  I also discovered that I was mistakenly using "selected" instead of "select"
as the attribute of the for-each...

Mark

> On Tue, 04 Apr 2000, you wrote:
> >
> > When I try to process the following XSLT, trying to test for the existence of an attribute called
> > "selected" in the current node:
> >
> >     <xsl:for-each selected="./@selected">
>
> Try self::node()[@selected] instead.
>
> -ed
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org



Re: SQL example

Posted by Laura Kruse <lm...@cis.ksu.edu>.
You need to add the xslt processor below the sql line, that should fix
you problem.
eg.

<?cocoon-process type="sql"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="news.xsl" type="text/xsl"?>

	- Laura

Edas Pazera wrote:
> 
> When I execute a SQL example, I get the same XML back with the Cocoon footer
> added.  I assume I should have received an XML structure instead.
> 
> Is this an indication that SQL Processor is not being called?  What should I
> try?
> 
> I do have "processor.type.sql =
> org.apache.cocoon.processor.sql.SQLProcessor" specified in cocoon.properties
> file.  The direct query against the database itself returns values, so it is
> not a database problem either.
> 
> For the reference, the code I am trying is:
> 
> <?xml version="1.0"?>
> 
> <?cocoon-process type="sql"?>
> <?cocoon-format type="text/xml"?>
> 
> <page>
> 
>  <connectiondefs>
>   <connection name="foo_connection">
>    <driver>org.gjt.mm.mysql.Driver</driver>
>    <dburl>jdbc:mysql://localhost/mydb</dburl>
>    <username></username>
>    <password></password>
>   </connection>
>  </connectiondefs>
> 
>  <query connection="foo_connection">
>   select ID from address
>  </query>
> 
> </page>

Re: SQL example

Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 4 Apr 2000, Edas Pazera wrote:

> When I execute a SQL example, I get the same XML back with the Cocoon footer
> added.  I assume I should have received an XML structure instead.
> 
> Is this an indication that SQL Processor is not being called?  What should I
> try?

Yes. SQL Processor's error reporting isn't very good. Look in your servlet
engine's jvm error logs for the exception's stack trace. Almost certainly
it's "failure to connect to data source" or some variation on that.

> 
> org.apache.cocoon.processor.sql.SQLProcessor" specified in cocoon.properties
> file.  The direct query against the database itself returns values, so it is
> not a database problem either.
> 
> For the reference, the code I am trying is:
> 
> <?xml version="1.0"?>
> 
> <?cocoon-process type="sql"?>
> <?cocoon-format type="text/xml"?>
> 
> <page>
> 
>  <connectiondefs>
>   <connection name="foo_connection">
>    <driver>org.gjt.mm.mysql.Driver</driver>
>    <dburl>jdbc:mysql://localhost/mydb</dburl>
>    <username></username>
>    <password></password>
>   </connection>
>  </connectiondefs>
> 
>  <query connection="foo_connection">
>   select ID from address
>  </query>
> 
> </page>

Try omitting the username and password elements - empty string is
different than null.

- donald


SQL example

Posted by Edas Pazera <ed...@usa.net>.
When I execute a SQL example, I get the same XML back with the Cocoon footer
added.  I assume I should have received an XML structure instead.

Is this an indication that SQL Processor is not being called?  What should I
try?

I do have "processor.type.sql =
org.apache.cocoon.processor.sql.SQLProcessor" specified in cocoon.properties
file.  The direct query against the database itself returns values, so it is
not a database problem either.

For the reference, the code I am trying is:

<?xml version="1.0"?>

<?cocoon-process type="sql"?>
<?cocoon-format type="text/xml"?>

<page>

 <connectiondefs>
  <connection name="foo_connection">
   <driver>org.gjt.mm.mysql.Driver</driver>
   <dburl>jdbc:mysql://localhost/mydb</dburl>
   <username></username>
   <password></password>
  </connection>
 </connectiondefs>

 <query connection="foo_connection">
  select ID from address
 </query>

</page>


Thanks,

Edas



Re: error testing attribute existence with for-each

Posted by Mark Dzmura <md...@digital-mission.com>.
I was trying to find some "exists()" function/predicate in the XSLT spec...
it didn't occur to me that I could just test an attribute!

Mark

> On Tue, 4 Apr 2000, Ed Knutson wrote:
>
> > On Tue, 04 Apr 2000, you wrote:
> > >
> > > When I try to process the following XSLT, trying to test for the existence of an attribute called
> > > "selected" in the current node:
> > >
> > >     <xsl:for-each selected="./@selected">
> >
> > Try self::node()[@selected] instead.
>
> and you can't do <xsl:if test="@selected"> why?
>
> - donald
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

--
)))) This email routed via a wireless gateway!! ((((



Re: error testing attribute existence with for-each

Posted by Donald Ball <ba...@webslingerZ.com>.
On Tue, 4 Apr 2000, Ed Knutson wrote:

> On Tue, 04 Apr 2000, you wrote:
> > 
> > When I try to process the following XSLT, trying to test for the existence of an attribute called
> > "selected" in the current node:
> > 
> >     <xsl:for-each selected="./@selected">
> 
> Try self::node()[@selected] instead.

and you can't do <xsl:if test="@selected"> why?

- donald


Re: error testing attribute existence with for-each

Posted by Ed Knutson <ed...@webcombo.net>.
On Tue, 04 Apr 2000, you wrote:
> 
> When I try to process the following XSLT, trying to test for the existence of an attribute called
> "selected" in the current node:
> 
>     <xsl:for-each selected="./@selected">

Try self::node()[@selected] instead.

-ed