}
// functional test in the actual xslt engine context
public void testTransform() throws Exception {
Component comp = new Component();
comp.getClients().add(Protocol.CLAP);
// here is the plan / setup
// * make a transformer from clap://**/xslt/one/1st.xsl
// * let it import a relative xsl ../two/2nd.xsl
// * let that in turn import a riap://component/three/3rd.xsl
// * provide input-xml-structure input/element-1st..-3rd/**
// * let each xsl call-in as well an extra document() 1st-3rd.xml with a
// simple <data>1st</data>
// * each xsl should provide the template for one of the lines
// * output should show all converted lines as read from the various
// external documents
String thirdDocData = "<data3>" + ("rnd." + (new Random()).nextInt())
+ "</data3>";
// Note below doesn't work,:
// final String xsl2xmlLink = "riap://application/3rd.xml";
// cause: the application-context one refers to with above is the one
// that is creating the xslt sheet
// (and the associated uri-resolver) Since that isn't an actual
// application-context so it doesn't support
// the riap-authority 'application'
// This does work though:
String xsl2xmlLink = "./3rd.xml"; // and "/three/3rd.xml" would
// too...
Representation xml3 = new StringRepresentation("<?xml version='1.0' ?>"
+ thirdDocData, MediaType.TEXT_XML);
Representation xslt3 = new StringRepresentation(
"<?xml version=\"1.0\"?>"
+ "<xsl:transform xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>"
+ " <xsl:template match ='el3'>"
+ " <xsl:variable name='external' select=\"document('"
+ xsl2xmlLink + "')\" />"
+ " <xsl:copy-of select='$external/data3' />"
+ " </xsl:template>" + "</xsl:transform>",
MediaType.TEXT_XML);
SimpleUriMapApplication thirdLevel = new SimpleUriMapApplication();
thirdLevel.add("3rd.xsl", xslt3);
thirdLevel.add("3rd.xml", xml3);
comp.getInternalRouter().attach("/three/", thirdLevel);
// xml In
Representation xmlIn = new StringRepresentation(
"<?xml version='1.0' ?><input><one/><any attTwo='2'/><el3>drie</el3></input>");
// xslOne
Reference xsltOneRef = new LocalReference("clap://thread/"
+ MY_BASEPATH + "/xslt/one/1st.xsl");
Representation xsltOne = comp.getContext().getClientDispatcher()
.handle(new Request(Method.GET, xsltOneRef)).getEntity();
TransformRepresentation tr = new TransformRepresentation(comp
.getContext(), xmlIn, xsltOne);
// TODO transformer output should go to SAX! The sax-event-stream should
// then be fed into a DOMBuilder
// and then the assertions should be written as DOM tests...