cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antony Grinyer" <antony.grin...@csw.co.uk>
Subject RE: XSLT transformation
Date Thu, 04 Aug 2005 18:05:20 GMT
I seem to have got a bit further with this issue. I think it's a Xalan
problem so I configured Cocoon to use Saxon instead which gives me a bit
more error detail during the transformation:

INFO    (2005-08-04) 18:50.52:052   [sitemap] (/kde/showsyscontainer)
PoolThread-4/BDBXMLTransformer: >>> Transformer Initialised
INFO    (2005-08-04) 18:50.52:130   [sitemap] (/kde/showsyscontainer)
PoolThread-4/HandleErrorsNode: Processing handle-errors at
file:/C:/cocoon-2.1.7/build/webapp/kde/sitemap.xmap:85:23
<file:/C:/cocoon-2.1.7/build/webapp/kde/sitemap.xmap:85:23> 
WARN    (2005-08-04) 18:50.52:318   [sitemap.serializer.html]
(/kde/showsyscontainer) PoolThread-4/AbstractTextSerializer: Cannot know
if transformer needs namespaces attributes - assuming NO.
org.xml.sax.SAXException: Saxon requires an XML parser that reports the
QName of each element

The code that generates the XML that is passed to the saxon XSLT
transformer is:

private void generateDocumentToSAX(String queryResults)
  {
    SAXParser parser = null;
    try
    {
      parser = (SAXParser)this.manager.lookup(SAXParser.ROLE);
      InputSource inputSource = new InputSource(new
StringReader(queryResults));
      parser.parse(inputSource, super.xmlConsumer);
    }
    catch(Exception e)
    {
      m_resultMessage = "Unable to get parser: " + e.toString();
      this.getLogger().error(m_resultMessage);
    }
    finally
    {
      if (parser != null) this.manager.release(parser);
    }
  }

Do I need to inform the parser in the code to do something to stop this
error below? WHat is the QName?

'Cannot know if transformer needs namespaces attributes - assuming NO.
org.xml.sax.SAXException: Saxon requires an XML parser that reports the
QName of each element'

Thanks,
Ant


> -----Original Message-----
> From: Antony Grinyer [mailto:antony.grinyer@csw.co.uk
<mailto:antony.grinyer@csw.co.uk> ]
> Sent: 04 August 2005 11:32 am
> To: users@cocoon.apache.org
> Subject: RE: XSLT transformation
>
> Thanks for your help Upayavira, I'm using Cocoon 2.1.7,
> however I'll try downloading a subversion client.
>
> I've attached the transformer Java class. Basically is takes
> an XML file which represents a query instruction. This query
> instruction is processed and is used to communicate with BDB
> XML containers. The queries return a standard XML file which
> should then be passed down the pipeline...as I mentioned it
> seems to output the XML correctly, but falls over when passed
> to an XSLT transformation.
>
> Any help would be 'greatly' appreciate...got to get this
> working today :-(
>
> > -----Original Message-----
> > From: Upayavira [mailto:uv@odoko.co.uk <mailto:uv@odoko.co.uk> ]
> > Sent: 04 August 2005 11:16 am
> > To: users@cocoon.apache.org
> > Subject: Re: XSLT transformation
> >
> > Try upgrading to the latest Cocoon 2.1.X from Subversion.
> > There are some improvements there that get around a
> tendency of Xalan
> > to swallow exceptions. You've got a NullPointerException happening,
> > but there's no mention of it in your stacktrace, so you're
> looking in
> > the wrong place for it.
> >
> > Download a subversion client (tortoisesvn.tigris.org if you're on
> > windows is good), then point it at
> > http://svn.apache.org/repos/asf/cocoon/branches/BRANCH_2_1_X
<http://svn.apache.org/repos/asf/cocoon/branches/BRANCH_2_1_X> .
> > You may well get better answers out of it.
> >
> > I still lean towards the problem being in your transformer.
> > Can you post some of the code for that here?
> >
> > Regards, Upayavira
> >
> > Antony Grinyer wrote:
> > > The stack trace returned is:
> > >
> > > ERROR   (2005-08-04) 09:46.59:112  
> > [sitemap.handled-errors] (/kde/listcontainers)
> > PoolThread-4/ErrorHandlerHelper: Error executing pipeline.
> > > org.apache.cocoon.ProcessingException: Error executing
> > pipeline.: java.lang.RuntimeException
> > >         at
> > org.apache.cocoon.components.pipeline.AbstractProcessingPipeli
> > ne.handleException(AbstractProcessingPipeline.java:940)
> > >         at
> > org.apache.cocoon.components.pipeline.impl.AbstractCachingProc
> > essingPipeline.processXMLPipeline(AbstractCachingProcessingPip
> > eline.java:281)
> > >         at
> > org.apache.cocoon.components.pipeline.AbstractProcessingPipeli
> > ne.process(AbstractProcessingPipeline.java:483)
> > >         at
> > >
> >
> org.apache.cocoon.components.treeprocessor.sitemap.SerializeNode.invok
> > > e(SerializeNode.java:120)
> > >
> > > << snip >>
> > >
> > > Caused by: java.lang.RuntimeException
> > >         at
> > org.apache.xalan.transformer.TransformerImpl.run(TransformerIm
> > pl.java:3418)
> > >         at
> > org.apache.xalan.transformer.TransformerHandlerImpl.endDocumen
> > t(TransformerHandlerImpl.java:389)
> > >         at
> > org.apache.cocoon.xml.AbstractXMLPipe.endDocument(AbstractXMLP
> > ipe.java:55)
> > >         at
> > org.apache.cocoon.transformation.TraxTransformer.endDocument(T
> > raxTransformer.java:560)
> > >         at
> > org.apache.cocoon.transformation.LogTransformer.endDocument(Lo
> > gTransformer.java:156)
> > >         at
> > org.apache.cocoon.xml.AbstractXMLPipe.endDocument(AbstractXMLP
> > ipe.java:55)
> > >         at
> > org.apache.cocoon.transformation.AbstractSAXTransformer.endDoc
> > ument(AbstractSAXTransformer.java:296)
> > >         at
> > org.apache.cocoon.components.sax.XMLTeePipe.endDocument(XMLTee
> > Pipe.java:67)
> > >         at
> > org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknow
> > n Source)
> > >         at
> > org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknow
> > n Source)
> > >         at
> > org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
> > >         at
> > org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
> > >         at
> > org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
> > >         at
> > org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDisp
> > atcher.dispatch(Unknown Source)
> > >         at
> > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocu
> > ment(Unknown Source)
> > >         at
> > org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> > >         at
> > org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> > >         at
> org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> > >         at
> > org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> > >         at
> > org.apache.excalibur.xml.impl.JaxpParser.parse(JaxpParser.java:296)
> > >         at
> > >
> org.apache.excalibur.xml.impl.JaxpParser.parse(JaxpParser.java:315)
> > >
> > >
> > > The XML generated by <map:transform type="bdbxml"/> is
> very simple:
> > >
> > > <?xml version="1.0" encoding="ISO-8859-1" ?>
> > >    <bdbxml-transaction transactiontype="retrieve"
> > containername="System.bdbxml" docname="syscontainer.xml">
> > >      <result status="passed">
> > >         <containers>
> > >           <container>
> > >             <name>Sample</name>
> > >            <filename>Sample.bdbxml</filename>
> > >            <docnamepath>/publication/metadata/title</docnamepath>
> > >            <paramsearchconfig>
> > >               <context
> > xpath="/publication/chapter">Chapter</context>
> > >               <context
> > xpath="/publication/chapter/section">Section</context>
> > >               <context
> > xpath="/publication/chapter/section/para">Paragraph</context>
> > >         </paramsearchconfig>
> > >       </container>
> > >    </containers>
> > >  </result>
> > > </bdbxml-transaction>
> > >
> > > And all I want to do is output the content of the container
> > elements child elements name and filename. This is the XSLT:
> > >
> > > <xsl:stylesheet version="1.0"
> > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<http://www.w3.org/1999/XSL/Transform> ">
> > >
> > >  <xsl:template match="/">
> > >   <html>
> > >    <body>
> > >     <xsl:apply-templates/>
> > >    </body>
> > >   </html>
> > >  </xsl:template>
> > >
> > >  <xsl:template match="result">
> > >   <xsl:apply-templates/>
> > >  </xsl:template>
> > >
> > >  <xsl:template match="containers">
> > >   <xsl:apply-templates/>
> > >  </xsl:template>
> > >
> > >  <xsl:template match="container">
> > >   Name:<xsl:value-of select="/name"/> Filename:<xsl:value-of
> > > select="/filename"/>  </xsl:template>
> > >
> > >  <xsl:template match="@*|node()" priority="-2">
> > >   <xsl:copy>
> > >    <xsl:apply-templates select="@*|node()"/>
> > >   </xsl:copy>
> > >  </xsl:template>
> > >
> > >  <xsl:template match="text()" priority="-1">
> > >   <xsl:value-of select="."/>
> > >  </xsl:template>
> > >
> > > </xsl:stylesheet>
> > >
> > >
> > >
> > > I've used the Cocoon log tranformer to catch what is coming
> > out of the
> > > bdbxml transformer anf I believe it looks okay:
> > >
> > > [setup] ---------------------------- [Thu Aug 04 09:59:35
> BST 2005]
> > > ---------------------------- [setDocumentLocator]
> > >
> >
> systemid=file:/C:/cocoon-2.1.7/build/webapp/kde/content/showsyscontain
<file:/C:/cocoon-2.1.7/build/webapp/kde/content/showsyscontain> 
> > > er.xml,publicid=null
> > > [startDocument]
> > > [startElement]
> uri=,local=bdbxml-transaction,raw=bdbxml-transaction
> > > [            ] 1.
> > uri=,local=transactiontype,qname=transactiontype,type=CDATA,va
> > lue=retrieve
> > > [            ] 2.
> > uri=,local=containername,qname=containername,type=CDATA,value=
> > System.bdbxml
> > > [            ] 3.
> > uri=,local=docname,qname=docname,type=CDATA,value=syscontainer.xml
> > > [startElement] uri=,local=result,raw=result
> > > [            ] 1.
> > uri=null,local=status,qname=status,type=CDATA,value=passed
> > > [setDocumentLocator] systemid=null,publicid=null [startDocument]
> > > [startElement] uri=,local=containers,raw=containers
> > > [startElement] uri=,local=container,raw=container
> > > [startElement] uri=,local=name,raw=name [characters] Sample
> > > [endElement] uri=,local=name,raw=name [startElement]
> > > uri=,local=filename,raw=filename [characters] Sample.bdbxm
> > > [characters] l [endElement] uri=,local=filename,raw=filename
> > > [startElement] uri=,local=docnamepath,raw=docnamepath
> > > [characters] /publication/metadata/title [endElement]
> > > uri=,local=docnamepath,raw=docnamepath
> > > [startElement] uri=,local=paramsearchconfig,raw=paramsearchconfig
> > > [startElement] uri=,local=context,raw=context
> > > [            ] 1.
> > uri=,local=xpath,qname=xpath,type=CDATA,value=/publication/chapter
> > > [characters] Chapter
> > > [endElement] uri=,local=context,raw=context [startElement]
> > > uri=,local=context,raw=context
> > > [            ] 1.
> > uri=,local=xpath,qname=xpath,type=CDATA,value=/publication/cha
> > pter/section
> > > [characters] Section
> > > [endElement] uri=,local=context,raw=context [startElement]
> > > uri=,local=context,raw=context
> > > [            ] 1.
> > uri=,local=xpath,qname=xpath,type=CDATA,value=/publication/cha
> > pter/section/para
> > > [characters] Paragraph
> > > [endElement] uri=,local=context,raw=context [endElement]
> > > uri=,local=paramsearchconfig,raw=paramsearchconfig
> > > [endElement] uri=,local=container,raw=container
> > > [endElement] uri=,local=containers,raw=containers
> > > [endDocument]
> > > [endElement] uri=,local=result,raw=result [endElement]
> > > uri=,local=bdbxml-transaction,raw=bdbxml-transaction
> > > [endDocument]
> > >
> > >
> > > Could this exception be Xalan related? I'm using jdk 1.4.2,
> > however I
> > > have copied across the xalan and xerces jars into the
> > jre/lib/endorsed
> > > directory as recommended by the Cocoon installations.
> > Should I try JDK 1.5?
> > >
> > > Strange thing is I've been able to do basic tranformation
> > on other XML
> > > using the file generator passed onto XSLT stylesheets (as
> > opposed my java transformer bdbxml).
> > >
> > > Any ideas? It's driving me mad!
> > >
> > > Thanks,
> > > Ant
> > >
> > >
> > >
> > >>-----Original Message-----
> > >>From: Upayavira [mailto:uv@odoko.co.uk <mailto:uv@odoko.co.uk> ]
> > >>Sent: 04 August 2005 08:57 am
> > >>To: users@cocoon.apache.org
> > >>Subject: Re: XSLT transformation
> > >>
> > >>Antony Grinyer wrote:
> > >>
> > >>>Hi,
> > >>>
> > >>>A have a simple sitemap entry as below:
> > >>>
> > >>><map:match pattern="listcontainers">
> > >>>  <map:generate type="file" src="content/showsyscontainer.xml"/>
> > >>>  <map:transform type="bdbxml"/>
> > >>>  <map:transform type="xslt" src="style/xsl/containerslist.xsl"/>
> > >>>  <map:serialize type="html"/>
> > >>></map:match>
> > >>>
> > >>>The generator is a simple XML file which is passed to a
> java class
> > >>>transformer ( referenced as type="bdbxml") which returns
> > >>
> > >>XML results.
> > >>
> > >>>This all works fine if I use <map:serialize type="xml"/>
> > to simply
> > >>>output the XML, however if I try to transform the XML
> > >>
> > >>output with the
> > >>
> > >>>XSLT transformer above I get an error:
> > >>>
> > >>>
> > >>>
> > >>>>>Error executing pipeline.
> > >>>
> > >>>
> > >>>>>org.apache.cocoon.ProcessingException: Error executing
> pipeline.:
> > >>>>>java.lang.RuntimeException
> > >>>
> > >>>
> > >>>I know the XSLT containerslist.xsl is correct as I've tried
> > >>
> > >>it against
> > >>
> > >>>some sample output XML in XMLSpy, but it appears that when
> > >>
> > >>I add this
> > >>
> > >>>XSLT transformer I get a Processing Exception?
> > >>>
> > >>>In the sitemap.log it is reported as:
> > >>>
> > >>>Unable to get parser: java.lang.RuntimeException:
> > >>>java.lang.NullPointerException
> > >>
> > >>Do you get any stack trace with this NPE?
> > >>
> > >>Your transformer is passing something down the pipeline as
> > null. This
> > >>isn't tripping up the XML serializer, but is tripping up the xslt
> > >>transformer. Go through each of the startElement, etc,
> calls within
> > >>your transformer looking at the output. See if you can see
> > any nulls
> > >>in there.
> > >>
> > >>Regards, Upayavira
> > >>
> > >>
> > >>------------------------------------------------------------
> > ---------
> > >>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > >>For additional commands, e-mail: users-help@cocoon.apache.org
> > >>
> > >>
> > >>
> > >>
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: Upayavira [mailto:uv@odoko.co.uk <mailto:uv@odoko.co.uk> ]
> > > Sent: Thu 8/4/2005 8:57 AM
> > > To: users@cocoon.apache.org
> > > Subject: Re: XSLT transformation
> > > 
> > > Antony Grinyer wrote:
> > >
> > >>Hi,
> > >>
> > >>A have a simple sitemap entry as below:
> > >>
> > >><map:match pattern="listcontainers">
> > >>  <map:generate type="file" src="content/showsyscontainer.xml"/>
> > >>  <map:transform type="bdbxml"/>
> > >>  <map:transform type="xslt" src="style/xsl/containerslist.xsl"/>
> > >>  <map:serialize type="html"/>
> > >></map:match>
> > >>
> > >>The generator is a simple XML file which is passed to a
> java class
> > >>transformer ( referenced as type="bdbxml") which returns
> > XML results.
> > >>This all works fine if I use <map:serialize type="xml"/> 
> to simply
> > >>output the XML, however if I try to transform the XML
> > output with the
> > >>XSLT transformer above I get an error:
> > >>
> > >>
> > >>
> > >>>>Error executing pipeline.
> > >>
> > >>
> > >>>>org.apache.cocoon.ProcessingException: Error executing
> pipeline.:
> > >>>>java.lang.RuntimeException
> > >>
> > >>
> > >>I know the XSLT containerslist.xsl is correct as I've tried
> > it against
> > >>some sample output XML in XMLSpy, but it appears that when
> > I add this
> > >>XSLT transformer I get a Processing Exception?
> > >>
> > >>In the sitemap.log it is reported as:
> > >>
> > >>Unable to get parser: java.lang.RuntimeException:
> > >>java.lang.NullPointerException
> > >
> > >
> > > Do you get any stack trace with this NPE?
> > >
> > > Your transformer is passing something down the pipeline as
> > null. This
> > > isn't tripping up the XML serializer, but is tripping up the xslt
> > > transformer. Go through each of the startElement, etc,
> calls within
> > > your transformer looking at the output. See if you can see
> > any nulls in there.
> > >
> > > Regards, Upayavira
> > >
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > > For additional commands, e-mail: users-help@cocoon.apache.org
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> ----------------------------------------------------------------------
> > > --
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
> >
> >
> 


Mime
View raw message