15. Exercise 3
In this exercise, you’ll compile an XSLT stylesheet into a SEF file.
Start in the “root” directory where you checked out the repository. (Up two levels from the exercise files.)
If you’re using Java, you can compile the stylesheet by running:
./gradlew -Pxsl=exercises/ex03/ex03.xsl eej
That’s the equivalent of running
java com.saxonica.Transform -xsl:exercises/ex03/ex03.xsl \-export:exercises/ex03/ex03.sef.json \-target:JS -nogo -relocate:on -ns:##html5
but using Gradle saves some typing and makes sure that the classpath and other Java infrastructure is set up correctly.
If you’re using Node, you can compile the stylesheet by running
./gradlew -Pxsl=exercises/ex03/ex03.xsl node_xslt3
That’s the equivalent of running
node node_modules/xslt3/xslt3.js -xsl:exercises/ex03/ex03.xsl \-export:exercises/ex03/ex03.sef.json \-nogo -ns:##html5
but using Gradle saves some typing and makes sure that the node environment is set up correctly.
Open up
ex03.xslin your favorite editor. Find thexsl:result-documentinstruction and addmethod="ixsl:replace-content"to it.Recompile the stylesheet. (This step is important!)
What effect do you think that will have on the result?
Load the answer into your browser: http://localhost:9000/exercises/ex03/
Did you remember to add the script lines?
Were you right about the effect of the
methodattribute?