views:

78

answers:

1

My output should be something like this:

<result>
  <item>
    <id>123</id>
    <src>123</src>
    <dst>123</dst>
  </item>
  <item>
  <!-- ... -->
  </item>
</result>

And the action class would have a method getFoos which returns an array of uniform objects, e. g. like this:

class Foo {
  // ...
  public long getId() { ... }
  // ...
}

I'm using the XSLTResult like this:

<action name="channels" method="loadAll" class="com.econemon.suite.api.impl.FooAction">
  <result name="success" type="xslt">
    <param name="exposedValue">foos</param>
  </result>
</action>

Since I don't want to postprocess the XML, I didn't specify any template, after reading several tutorials that said this would work. Instead, it gives me this error:

javax.xml.transform.TransformerException: Operation not supported. - [unknown location]

So I tried using a template, but it never rendered a list at all. Instead I get

  • all properties of the beans toString()ed together
  • empty document
  • empty <foo /> tag (not <foos />, strangely)

I couldn't find a tutorial that helped me, neither on Beans->XML rendering nor XSLT. One problem is that I have trouble coming up with good search terms: googling "struts xml" and similar returns a huge amount of completely irrelevant links about stuff in struts.xml, excluding "struts.xml" from the results is no good either, because pages I'm looking for would likely have example struts.xml snippets.

I think I wouldn't really need the templates, so if it's possible to do without, great.

A: 

Some commenters on this blog post had the same error you mentioned. Maybe on of the posted workaround will help?

http://cse-mjmcl.cse.bris.ac.uk/blog/2007/09/10/1189430125294.html

Nate
I had looked at those before, too, it's pratically the only useful thing I was able to google. I have a template now that doesn't do any transformation at all, much like the workarounds you mentioned. Still, I'm wondering whether this is really how it's supposed to work and why both the documentation and online resources are so bad.
Hanno Fietz