James,
> From: James Strachan [mailto:[EMAIL PROTECTED]]
>
> From: "Wannheden, Knut" <[EMAIL PROTECTED]>
> >
> > <xu:assertDocumentsEqual xmls:xu="jelly:xmlunit">
> > <xu:expected evalBody="false">
> > <j:set var="x" value="y"/>
> > <j:set var="x2" value="y2"/>
> > </xu:expected>
> > <xu:actual evalBody="true">
> > <my:getSetupSricpt/>
> > </xu:actual>
> > </xu:assertDocumentsEqual>
> >
> > (Note the fictional evalBody attribute.) The previous
> would be a test
> case
> > for the <my:getSetupScript/> tag. The tag could maybe be
> used like this:
> >
> > <j:eval>
> > <my:getSetupScript/>
> > </j:eval>
> >
> > which would actually execute the two <j:set/> tags.
> >
> > Does this seem too wacky?
>
> :-). No I don't think so. I think we probably need a way to
> say 'treat this
> block of Jelly script as just XML'. I'm not sure exactly why
> we need this
> but a few people seem to hit this issue. Maybe we could just
> have a special
> Jelly-compiler directive of some kind to treat a block as
> just XML and to
> not expand any tags or expressions.
>
> e.g. something like
>
> <j:literal>
> <j:set var="x" value="1234"/>
> </j:literal>
>
Or maybe the Tag and Script interfaces could just be extended by a getXML()
method. In the case of a Tag an Element would be reeturned, and in the case
of a Script maybe a List. Or is there a notion of XML fragments in dom4j?
Then the <xu:expected/> and <xu:actual/> could do something like this:
AssertDocumentsEqualTag assertTag =
(AssertDocumentsEqualTag)
findAncestorWithClass(AssertDocumentsEqualTag.class);
if (evalBody) {
SAXContentHandler handler = new SAXContentHandler();
XMLOutput newOutput = new XMLOutput(handler);
handler.startDocument();
invokeBody(newOutput);
handler.endDocument();
assertTag.setExpected(handler.getDocument());
} else {
assertTag.setExpected(createDocument(getBody().getXML()));
}
(Note the createDocument() which would have to be implemented.)
This would of course require Tags and Scripts to store their serialized XML
form.
How do you feel about this idea?
--
knut