Christopher Oliver wrote:

I tried this and it seems to work fine - except for #{query/music/title/text()} which caused a NullPointerException. I just checked in a fix for that.

I just updated to the latest CVS, and your fix has made text() work. Thanks.


What version are you using? Here's what I got:

#{query/music/title} => Song

Hmm. Still not working. So, I've set up a more thorough test environment, and let me detail again what's going on:


Sitemap:
<map:match pattern="test">
<map:call function="test"/>
</map:match>
<map:match pattern="test-pipe">
<map:generate type="jx" src="xml/test.jx"/>
<map:serialize type="xml"/>
</map:match>


Flow:
function test() {
var builder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
var test = builder.parse(new java.io.File("d:/documents/cocoon/tuneballoon/site/xml/test.xml").toURL().toExternalForm());
print ("Test node:" + test.getDocumentElement().getNodeName());
cocoon.sendPage("test-pipe", {"test": test});
}


JXTemplate (xml/test.jx):
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0";>
<content>
TITLE:{#{test/music/title}}
TITLE2:(#{test/music/title/text()})
<table>
<jx:forEach select="#{test/music/arrangements/arrangement">
<tr><td>TITLES:#{./title}</td></tr>
</jx:forEach>
</table>
</content>
</page>


Sample XML (xml/test.xml):
<music>
 <title>Song</title>
 <arrangements>
   <arrangement>
     <title>Arr1</title>
   </arrangement>
   <arrangement>
     <title>Arr2</title>
   </arrangement>
 </arrangements>
</music>

Now, if in the within the jx:forEach I do #{.}, I get 'TITLES:[EMAIL PROTECTED]'.

If I do #{./title}, I get:
file:/d:/documents/cocoon/tuneballoon/site/xml/test.jx:9:35:org.apache.commons.jxpath.JXPathException: No pointer for xpath: ./title


If I do #{./title/text()}, I get:<tr><td>TITLES:</td></tr>, i.e. nothing back.

For the first two jxpaths, I get 'Song' for #{test/music/title/text()}, correctly, but <title>Song</title> for #{test/music/title}.

Perhaps you could send me the files for your working version, and I can see if I can get them to work here?

Thanks for your help.

Regards, Upayavira


<jx:forEach select="#{query/music/arrangements/arrangement}"> title: #{./title}, </jx:forEach> => title: Arr1, title: Arr2

Regards,

Chris


Upayavira wrote:


I've got two problems with JXTemplateGenerator. To start with, here's an XML:

<music>
 <title>Song</title>
 <arrangements>
   <arrangement>
     <title>Arr1</title>
   </arrangement>
   <arrangement>
     <title>Arr2</title>
   </arrangement>
 </arrangements>
</music>

1) If I call the page with this in a DOM, with the name 'query', if I do #{query/music/title}, it returns <title>Song</title>, not 'Song'. #{query/music/title/text()} doesn't return anything, neither does string() or node().

2) If I use
<jx:forEach select="#{query/music/arrangements/arrangement">
      <tr><td>title: :#{./title}</td></tr>
</jx:forEach>

It shows one 'title:' heading, not two. But #{./title} returns nothing. Everything I've tried still returns nothing.

Any pointers?

Thanks, Upayavira



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to