XSL and XML Intro xml xml version 1
- Slides: 63
XSL and XML
Intro. xml <? xml version = "1. 0"? > <!-- Fig. 12. 2 : intro. xml --> <!-- Simple introduction to XML markup --> <? xml: stylesheet type = "text/xsl" href = "intro. xsl"? > <my. Message> <message>xyz 123!</message> <message>Welcome to XSLT!</message> <message>hello!</message> <message>goodbye!</message> </my. Message>
Intro. xsl processes intro. xml <? xml version = "1. 0"? > <!-- Fig. 12. 1 : intro. xsl --> <!-- Simple XSLT document for intro. xml --> <xsl: stylesheet version = "1. 0" xmlns: xsl = "http: //www. w 3. org/1999/XSL/Transform"> <xsl: template match = "my. Message"> <html> <body><xsl: value-of select = "message"/></body> </html> </xsl: template> </xsl: stylesheet>
In IE
Modifying the xsl: apply-templates with no template specified will print all children of my. Message <? xml version = "1. 0"? > <!-- Fig. 12. 1 : intro. xsl --> <!-- Simple XSLT document for intro. xml --> <xsl: stylesheet version = "1. 0" xmlns: xsl = "http: //www. w 3. org/1999/XSL/Transform"> <xsl: template match = "my. Message"> <html> <body><xsl: apply-templates/></body> </html> </xsl: template> </xsl: stylesheet>
In IE
Match =“/” finds the root, apply-templates with no nodes specified prints all children of root (same output as the last example) <? xml version = "1. 0"? > <!-- Simple XSLT document for intro. xml --> <xsl: stylesheet version = "1. 0" xmlns: xsl = "http: //www. w 3. org/1999/XSL/Transform"> <xsl: template match = "/"> <html> <body><xsl: apply-templates/></body> </html> </xsl: template> </xsl: stylesheet>
Using an xsl to create a modified xml from a given document • It is inconvenient and perhaps impossible to edit the xml to include a reference to an xsl document that will process it. • A more likely scenario is to run a process on an xml document using a given xsl to reformat the xml for another purpose.
Example uses Xalan • Xalan. jar and Xerces. jar must be in your classpath. • If Xalan is in a directory under c called xalan, you can create a batch file or type on the commandline Set classpath=c: xalan. jar; c: xalanxerces. jar javabin>java org. apache. xalan. xslt. Process -INDENT 3 -IN games. xml XSL elements. xsl -OUT output. xml Alternatively you can set the classpath environment variable from control panel/system/advanced. Here is my current classpath variable value: C: xerces 1_2_0xerces. jar; c: progra~1javajdk 15~1. 0_0libtools. jar; c: progra~1javaj dk 15~1. 0_0bin; c: jakartajakart~1. 28commonlib; C: Xalanxalanj_1_2_D 02xalan. jar
Using an xsl to create a modified xml from a given document Microsoft(R) Windows DOS (C)Copyright Microsoft Corp 1990 -2001. C: PROGRA~1JAVAJDK 15~1. 0_0BIN>java org. apache. xalan. xslt. Process -INDENT 3 I N games. xml -XSL elements. xsl -OUT output. xml ===== Parsing file: C: /PROGRA~1/Java/JDK 15~1. 0_0/bin/elements. xsl ===== Parse of file: C: /PROGRA~1/Java/JDK 15~1. 0_0/bin/elements. xsl took 390 millisecond s ===== Parsing file: C: /PROGRA~1/Java/JDK 15~1. 0_0/bin/games. xml ===== Parse of file: C: /PROGRA~1/Java/JDK 15~1. 0_0/bin/games. xml took 40 milliseconds =============== Transforming. . . transform took 10 milliseconds XSLProcessor: done C: PROGRA~1JAVAJDK 15~1. 0_0BIN>
The original xml <? xml version = "1. 0"? > <!-- Fig. 12. 4 : games. xml --> <!-- Sports Database --> <sports> <game title = "cricket"> <id>243</id> <para> More popular among commonwealth nations. </para> </game> <game title = "baseball"> <id>431</id> <para> More popular in America. </para> </game> <game title = "soccer"> <id>123</id> <para> Most popular sport in the world. </para> </game> </sports>
<? xml version = "1. 0"? > The xsl <!-- Fig. 12. 5 : elements. xsl --> <!-- Using xsl: element and xsl: attribute --> <xsl: stylesheet version = "1. 0" xmlns: xsl = "http: //www. w 3. org/1999/XSL/Transform"> <xsl: template match = "/"> <xsl: apply-templates/> </xsl: template> <xsl: template match = "sports"> <sports> <xsl: apply-templates/> </sports> </xsl: template> <xsl: template match = "game"> <xsl: element name = "{@title}"> <xsl: attribute name = "id"> <xsl: value-of select = "id"/> </xsl: attribute> <comment> <xsl: value-of select = "para"/> </comment> </xsl: element> </xsl: template> </xsl: stylesheet>
Output. xml <? xml version="1. 0" encoding="UTF-8"? > <sports> <cricket id="243"> <comment> More popular among commonwealth nations. </comment> </cricket> <baseball id="431"> <comment> More popular in America. </comment> </baseball> <soccer id="123"> <comment> Most popular sport in the world. </comment> </soccer> </sports>
Xsl can perform iteration and sorting and generate an html output <? xml version = "1. 0"? > <!-- Fig. 12. 7 : usage. xml --> <!-- Usage of elements and attributes --> <? xml: stylesheet type = "text/xsl" href = "usage. xsl"? > <book isbn = "999 -99999 -9 -X"> <title>Deitel' s XML Primer</title> <author> <first. Name>Paul</first. Name> <last. Name>Deitel</last. Name> </author> <chapters> <preface num = "1" pages = "2">Welcome</preface> <chapter num = "1" pages = "4">Easy XML</chapter> <chapter num = "2" pages = "2">XML Elements? </chapter> <appendix num = "1" pages = "9">Entities</appendix> </chapters> <media type = "CD"/> </book>
The stylesheet • In notes • Opening the xml in IE or Xalan will display the rendered html
In IE
Day planner. xml from chpt 5 transformed via xsl into html <? xml version = "1. 0"? > <!-- planner. xml --> <!-- Day Planner XML document --> <!—next line missing from text needed to get xsl to render this document in browser--> <? xml: stylesheet type = "text/xsl" href = "conditional. xsl"? > <planner> <year value = "2000"> <date month = "7" day = "15"> <note time = "1430">Doctor' s appointment</note> <note time = "1620">Physics class at BH 291 C</note> </date> <date month = "7" day = "4"> <note>Independence Day</note> </date> <date month = "7" day = "20"> <note time = "0900">General Meeting in room 32 -A</note> </date> <date month = "7" day = "20"> <note time = "1900">Party at Joe' s</note> </date> <date month = "7" day = "20"> <note time = "1300">Financial Meeting in room 14 -C</note> </date> </year> </planner>
Xsl document in notes
Intro. xml from earlier, modified to have copy. Intro. xsl applied to it <? xml version = "1. 0"? > <!-- Fig. 12. 2 : intro. xml --> <!-- Simple introduction to XML markup --> <? xml: stylesheet type = "text/xsl" href = "copy. Intro. xsl"? > <my. Message> <message>Welcome to XSLT!</message> </my. Message>
The stylesheet uses copy element <? xml version = "1. 0"? > <!-- Fig. 12: copy. Intro. xsl --> <!-- xsl: copy example using Intro. xml --> <xsl: stylesheet version = "1. 0" xmlns: xsl = "http: //www. w 3. org/1999/XSL/Transform"> <xsl: template match = "my. Message"> <xsl: copy> <xsl: apply-templates/> </xsl: copy> </xsl: template> <xsl: template match = "message"> <xsl: copy> How about ' Hi World' for a change! </xsl: copy> </xsl: template> </xsl: stylesheet>
Result of copy nodes in IE
Copying nodes: intro. xml uses unsing. Copy. Of. xsl <? xml version = "1. 0"? > <!-- Fig. 12. 2 : intro. xml --> <!-- Simple introduction to XML markup --> <? xml: stylesheet type = "text/xsl" href = "using. Copy. Of. xsl"? > <my. Message> <message>Welcome to XSLT!</message> </my. Message>
using. Copy. Of. xsl <? xml version = "1. 0"? > <!-- Fig. 12. 14 : using. Copy. Of. xsl --> <!-- xsl: copy-of example using intro. xml --> <xsl: stylesheet version = "1. 0" xmlns: xsl = "http: //www. w 3. org/1999/XSL/Transform"> <xsl: template match = "my. Message"> <xsl: comment> The following XML tree has been copied into output. </xsl: comment> <xsl: copy-of select = ". "/> </xsl: template> </xsl: stylesheet>
IE output
Output value <? xml version = "1. 0"? > <!-- Fig. 12. 2 : intro. xml --> <!-- Simple introduction to XML markup --> <? xml: stylesheet type = "text/xsl" href = "using. Copy. Of. xsl"? > <my. Message> <message>Welcome to XSLT!</message> </my. Message>
An XSL can import another XSL • <? xml version = "1. 0"? > • • <!-- Fig. 12. 17 : usage 1. xsl --> <!-- xsl: import example using usage. xml --> • • <xsl: stylesheet version = "1. 0" xmlns: xsl = "http: //www. w 3. org/1999/XSL/Transform"> • <xsl: import href = "usage 2. xsl"/> • • • <!-- This template has higher precedence over the templates being imported --> <xsl: template match = "title"> • • • <h 2> <xsl: value-of select = ". "/> </h 2> • </xsl: template> • </xsl: stylesheet>
An XSL can import another XSL <? xml version = "1. 0"? > <!-- Fig. 12. 16 : usage 2. xsl --> <!-- xsl: import example --> <xsl: stylesheet version = "1. 0" xmlns: xsl = "http: //www. w 3. org/1999/XSL/Transform"> <xsl: template match = "book"> <html> <body> <xsl: apply-templates/> </body> </html> </xsl: template> <xsl: template match = "title"> <xsl: value-of select = ". "/> </xsl: template> <xsl: template match = "author"> <br/> <p>Author: <xsl: value-of select = "last. Name"/>, <xsl: value-of select = "first. Name"/> </p> </xsl: template> <xsl: template match = "*|text()"/> </xsl: stylesheet>
The xml <? xml version = "1. 0"? > <!-- Fig. 12. 8 : usage. xml --> <!-- Usage of elements and attributes --> <!– using usage 1 which imports usage 2. xsl --> <? xml: stylesheet type = "text/xsl" href = "usage 1. xsl"? > <book isbn = "999 -99999 -9 -X"> <title>Deitel's XML Primer</title> <author> <first. Name>Paul</first. Name> <last. Name>Deitel</last. Name> </author> <chapters> <preface num = "1" pages = "2">Welcome</preface> <chapter num = "1" pages = "4">Easy XML</chapter> <chapter num = "2" pages = "2">XML Elements? </chapter> <appendix num = "1" pages = "9">Entities</appendix> </chapters> <media type = "CD"/> </book>
In IE
In IE, with just usage 2. xsl
Axes. xml • In notes • <? xml: stylesheet type = "text/xsl" href = "axes. xsl"? > added to xml
Axes. xsl • In notes
Html output
This can also be run from the commandline using Xalan Microsoft(R) Windows DOS (C)Copyright Microsoft Corp 1990 -2001. C: PROGRA~1JAVAJDK 15~1. 0_0BIN>java org. apache. xalan. xslt. Process -INDENT 3 I N axes. xml -XSL axes. xsl -OUT axes. html ===== Parsing file: C: /PROGRA~1/Java/JDK 15~1. 0_0/bin/axes. xsl ===== Parse of file: C: /PROGRA~1/Java/JDK 15~1. 0_0/bin/axes. xsl took 411 milliseconds ===== Parsing file: C: /PROGRA~1/Java/JDK 15~1. 0_0/bin/axes. xml ===== Parse of file: C: /PROGRA~1/Java/JDK 15~1. 0_0/bin/axes. xml took 70 milliseconds =============== Transforming. . . transform took 80 milliseconds XSLProcessor: done C: PROGRA~1JAVAJDK 15~1. 0_0BIN>
More Xalan samples an applet to convert xml to html
client. html is javascript that runs the applet locally if the paths to xalan and xerces are correct <!doctype HTML public "-//W 3 C//DTD HTML 4. 0 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <script language="Java. Script"> var target=""; function write. Source() { var source. String=document. xsl. Control. get. Source. Tree. As. Text(); var esc. String=document. xsl. Control. escape. String(source. String); var title="XML Source Doc"; var doc=top. frames[1]. document; doc. open(); doc. write("<h 3>" + title + "</h 3>"); doc. write("<PRE>"); doc. write(esc. String); doc. write("</PRE>"); doc. close(); } function write. Stylesheet() { var style. String=document. xsl. Control. get. Style. Tree. As. Text(); var esc. String=document. xsl. Control. escape. String(style. String); var title="XSL Stylesheet"; var doc=top. frames[2]. document; doc. open(); doc. write("<h 3>" + title + "</h 3>"); doc. write("<PRE>"); doc. write(esc. String); doc. write("</PRE>"); doc. close(); }
slide 2 of javascript function write. Target() { var doc=top. frames[3]. document; doc. open(); var title="HTML Output"; doc. write("<h 3>" + title + "</h 3>"); if (document. xml. Transform. display. Mode[0]. checked) //display HTML { doc. write(target); } else // display source { var esc. String=document. xsl. Control. escape. String(target); doc. write("<PRE>"); doc. write(esc. String); doc. write("</PRE>"); } doc. close(); } function clear. Frames() { document. xsl. Control. free. Cache(); for (i=1; i<4; i++) { var doc=top. frames[i]. document; doc. open(); doc. clear(); doc. close(); } }
slide 3 of javascript function transform() { clear. Frames(); var xml. Source=document. xml. Transform. xml. Source. List. options[docume nt. xml. Transform. xml. Source. List. selected. Index]. value; document. xsl. Control. set. Document. URL(xml. Source); target=document. xsl. Control. get. Html. Text(); // alert("Output: " + target); write. Source(); write. Stylesheet(); write. Target(); }
slide 4 of javascript </script> <body on. Load="clear. Frames(); " bgcolor="#808080" text="#ffffff"> <form name="xml. Transform" action="" method="POST"> <h 2><img border="0" hspace="0" vspace="0" align="left" src="rabbitwhorn. jpg"> Transform XML Document</h 2> <table> <tr> <td width="50"></td> <td align="center"><i>Document to transform</i></td> <td align="center"><i>Display output as</i></td> </tr> <td></td> <td align="center"> <select name="xml. Source. List"> <option value="xalan. Applets. xml" selected> xalan. Applets. xml <option value="foo-s 1. xml"> foo-s 1. xml </select> </td> <td align="center"> <input type="radio" name="display. Mode" checked>HTML <input type="radio" name="display. Mode">HTML Source </td> <td> <input type="button" name="transform. Button" value="Transform" on. Click="transform(); "> </td> </tr> </table> </form>
slide 5 of javascript <!-- Be sure you have applet archive attribute set so the applet can find xalan. jar and xerces. jar --> <applet name="xsl. Control" code="org. apache. xalan. xslt. client. XSLTProcessor. Applet. class" archive=". . /xalan. jar, . . /xerces. jar" height="0" width"0"> <param name="document. URL" value="xalan. Applets. xml"/> <!-default setting--> <param name="style. URL" value="s 1 To. HTML. xsl"/> <!--doesn't change--> </applet> </body> </html>
batch file This batch file expect a single parameter, the name of the directory (and java class file) to be run in the Xalan samples. It works ok for Simple. Transform. To. Dom seems to have an error. set PATH=%PATH%; C: Progra~1Javajdk 15. 0_0bin set CLASSPATH=%CLASSPATH%; c: xerces 1_2_0xerces. jar; c: xalanj_1_2_D 02xalan. jar; c: xalanj_1_2_D 02samplesxalansamples. jar cd c: xalan-j_1_2_D 02samples%1 java %1
screen from Simple. Transform (another Xalan example) C: XALAN-~1SAMPLES>java. Xalan Simple. Transform C: xalanXALAN-~1samples>set PATH=C: WINDOWSsystem 32; C: WINDOWSSys tem 32Wbem; C: PROGRA~1COMMON~1ADAPTE~1System; C: jakartaJAKART~1. 28bin; c: pr ogra~1javajdk 15~1. 0_0bin; c: jakartajakart~1. 28commonlib; ; C: Progra~1Java jdk 15. 0_0bin C: xalanXALAN-~1samples>set CLASSPATH=C: xerces-1_2_0xerces. jar; c: progra~1j avajdk 15~1. 0_0libtools. jar; c: progra~1javajdk 15~1. 0_0bin; c: progra~1java jdk 15~1. 0_0binhello; c: jakartajakart~1. 28commonlib; C: Xalanxalan-j_1_2_D 02 xalan. jar; c: xerces-1_2_0xerces. jar; c: xalan-j_1_2_D 02xalan. jar; c: xala nxalan-j_1_2_D 02samplesxalansamples. jar C: xalanXALAN-~1samples>cd c: xalan-j_1_2_D 02samplesSimple. Transform C: Xalanxalan-j_1_2_D 02samplesSimple. Transform>java Simple. Transform <? xml version="1. 0" encoding="UTF-8"? > <out>Hello</out> C: XALAN-~1SAMPLES>
Transform. To. Dom results C: xalanXALAN-~1samples>cd c: xalan-j_1_2_D 02samplesTransform. To. Dom C: Xalanxalan-j_1_2_D 02samplesTransform. To. Dom>java Transform. To. Dom XSL Error: Cannot use a DTMLiaison for an output DOM node. . . pass a org. apache. x alan. xpath. xdom. Xerces. Liaison instead! XSL Error: SAX Exception in thread "main" org. apache. xalan. xslt. XSLProcessor. Exception: at org. apache. xalan. xslt. XSLTEngine. Impl. error(XSLTEngine. Impl. java: 1720) at org. apache. xalan. xslt. XSLTEngine. Impl. error(XSLTEngine. Impl. java: 1612) at org. apache. xalan. xslt. Stylesheet. Root. process(Stylesheet. Root. java: 395) at org. apache. xalan. xslt. XSLTEngine. Impl. process(XSLTEngine. Impl. java: 647) at Transform. To. Dom. main(Transform. To. Dom. java: 99) C: XALAN-~1SAMPLES>
running Xalan directly on foo. xml, foo. xsl C: XALAN-~1SAMPLESTRANSF~1>run. Xalan C: xalanXALAN-~1samplesTRANSF~1>java org. apache. xalan. xslt. Process -INDENT 3 -IN foo. xml -XSL foo. xsl -OUT output. xml ===== Parsing file: C: /xalan/XALAN-~1/samples/TRANSF~1/foo. xsl ===== Parse of file: C: /xalan/XALAN-~1/samples/TRANSF~1/foo. xsl took 260 milliseconds ===== Parsing file: C: /xalan/XALAN-~1/samples/TRANSF~1/foo. xml ===== Parse of file: C: /xalan/XALAN-~1/samples/TRANSF~1/foo. xml took 30 milliseconds =============== Transforming. . . transform took 10 milliseconds XSLProcessor: done C: XALAN-~1SAMPLESTRANSF~1>type output. xml <? xml version="1. 0" encoding="UTF-8"? > <out>Hello</out> C: XALAN-~1SAMPLESTRANSF~1>
This batch file works in the appropriate Xalan subdirectory if your java jdk is in your path: java org. apache. xalan. xslt. Process -INDENT 3 -IN %1 -XSL %2 -OUT %3
a xalan example to create xpath C: XALAN-~1SAMPLES>xpath Apply. XPath foo. xml / C: xalanXALAN-~1samples>set PATH=C: WINDOWSsystem 32; C: WINDOWSSys tem 32Wbem; C: PROGRA~1COMMON~1ADAPTE~1System; C: jakartaJAKART~1. 28bin; c: pr ogra~1javajdk 15~1. 0_0bin; c: jakartajakart~1. 28commonlib; ; C: Progra~1Java jdk 15. 0_0bin C: xalanXALAN-~1samples>set CLASSPATH=C: xerces-1_2_0xerces. jar; c: progra~1j avajdk 15~1. 0_0libtools. jar; c: progra~1javajdk 15~1. 0_0bin; c: progra~1java jdk 15~1. 0_0binhello; c: jakartajakart~1. 28commonlib; C: Xalanxalan-j_1_2_D 02 xalan. jar; c: xerces-1_2_0xerces. jar; c: xalan-j_1_2_D 02xalan. jar; c: xala nxalan-j_1_2_D 02samplesxalansamples. jar C: xalanXALAN-~1samples>cd c: xalan-j_1_2_D 02samplesApply. XPath C: Xalanxalan-j_1_2_D 02samplesApply. XPath>java Apply. XPath foo. xml /doc/name/@f irst <output> David. Donald. Emily. Jack. Myriam. Paul. Robert. Scott. Shane</output> C: XALAN-~1SAMPLES>
test file foo. xml <? xml version="1. 0"? > <doc> <name first="David" last="Marston"/> <name first="David" last="Bertoni"/> <name first="Donald" last="Leslie"/> <name first="Emily" last="Farmer"/> <name first="Jack" last="Donohue"/> <name first="Myriam" last="Midy"/> <name first="Paul" last="Dick"/> <name first="Robert" last="Weir"/> <name first="Scott" last="Boag"/> <name first="Shane" last="Curcuru"/> </doc>
XPath example in Xalan • Batch file for Apply. XPath. DOM. java (note it takes 2 parameters): set PATH=%PATH%; C: Progra~1Javajdk 15. 0_0bin set CLASSPATH=%CLASSPATH%; c: xerces 1_2_0xerces. jar; c: xerces-1_2_0xerces. Samples. jar set CLASSPATH=%CLASSPATH%; c: xalan-j-currentbinxalan-j_2_6_0binxalan. jar; c: xalan-j-currentbinxalan-j_2_6_0binxalansamples. jar cd c: xalan-j-current-binxalanj_2_6_0samplesApply. XPath. DOM java Apply. XPath. DOM %1 %2
XPath example in Xalan: results of asking for all name node descendants of root (//name) C: xalan-j-current-binxalan-j_2_6_0samplesApply. XPath. DOM>java Apply. XPath. DOM fo o. xml //name Loading classes, parsing foo. xml, and setting up serializer Querying DOM using //name <output> <name first="David" last="Marston"/> <name first="David" last="Bertoni"/> <name first="Donald" last="Leslie"/> <name first="Emily" last="Farmer"/> <name first="Joseph" last="Kesselman"/> <name first="Myriam" last="Midy"/> <name first="Paul" last="Dick"/> <name first="Stephen" last="Auriemma"/> <name first="Scott" last="Boag"/> <name first="Shane" last="Curcuru"/> </output>
running Apply. XPath on foo. xml with another parameter C: xalanXALAN-~1samplesAPPLYX~1>set CLASSPATH=C: xerces 1_2_0xerces. jar; c: p rogra~1javajdk 15~1. 0_0libtools. jar; c: progra~1javajdk 15~1. 0_0bin; c: progr a~1javajdk 15~1. 0_0binhello; c: jakartajakart~1. 28commonlib; C: Xalanxalanj_1_2_D 02xalan. jar; c: xerces-1_2_0xerces. jar; c: xalan-j_1_2_D 02xalan. ja r; c: xalan-j_1_2_D 02samplesxalansamples. jar C: xalanXALAN-~1samplesAPPLYX~1>cd c: xalanj_1_2_D 02samplesApply. XPat h C: Xalanxalan-j_1_2_D 02samplesApply. XPath>java Apply. XPath foo. xml /doc/name/@l ast <output> Marston. Bertoni. Leslie. Farmer. Donohue. Midy. Dick. Weir. Boag. Curcuru</output> C: XALAN-~1SAMPLESAPPLYX~1>
Compiling xalan examples from the commandline C: PROGRA~1JAVAJDK 15~1. 0_0BIN>javac c: xalan-j-currentbinxalan-j_2_6_0samplesSimple. Transform. java
Running from javabin • I copied birds. * from the sample directory to my bin • java -classpath C: xalan-j-current-binxalanj_2_6_0binxalan. jar; C: xalan-j-current-binxalan -j_2_6_0binxerces. Impl. jar; C: xalan-j-currentbinxalan-j_2_6_0samplesSimple. Transform • Creates a file birds. out
A portion of Birds. xml <? xml version="1. 0" encoding="UTF-8"? > <Class> <Order Name="TINAMIFORMES"> <Family Name="TINAMIDAE"> <Species Scientific_Name="Tinamus major"> Great Tinamou. </Species> <Species Scientific_Name="Nothocercus">Highland Tinamou. </Species> <Species Scientific_Name="Crypturellus soui">Little Tinamou. </Species> <Species Scientific_Name="Crypturellus cinnamomeus">Thicket Tinamou. </Species> <Species Scientific_Name="Crypturellus boucardi">Slaty-breasted Tinamou. </Species> <Species Scientific_Name="Crypturellus kerriae">Choco Tinamou. </Species> </Family> </Order> <Order Name="GAVIIFORMES"> <Family Name="GAVIIDAE"> <Species Scientific_Name="Gavia stellata">Red-throated Loon. </Species> <Species Scientific_Name="Gavia arctica">Arctic Loon. </Species> <Species Scientific_Name="Gavia pacifica">Pacific Loon. </Species> <Species Scientific_Name="Gavia immer">Common Loon. </Species> <Species Scientific_Name="Gavia adamsii">Yellow-billed Loon. </Species> </Family> </Order>
Birds. xsl <? xml version="1. 0"? > <xsl: stylesheet xmlns: xsl="http: //www. w 3. org/1999/XSL/Transform" version="1. 0"> <xsl: output method="xml" indent="yes"/> <xsl: template match="Class"> <Bird. Info> <xsl: apply-templates select="Order"/> </Bird. Info> </xsl: template> <xsl: template match="Order"> Order is: <xsl: value-of select="@Name"/> <xsl: apply-templates select="Family"/><xsl: text> </xsl: template> <xsl: template match="Family"> Family is: <xsl: value-of select="@Name"/> <xsl: apply-templates select="Species | Sub. Family | text()"/> </xsl: template> <xsl: template match="Sub. Family"> Sub. Family is <xsl: value-of select="@Name"/> <xsl: apply-templates select="Species | text()"/> </xsl: template> <xsl: template match="Species"> <xsl: choose> <xsl: when test="name(. . )='Sub. Family'"> <xsl: text> </xsl: text><xsl: value-of select=". "/><xsl: text> </xsl: text><xsl: value-of select="@Scientific_Name"/> </xsl: when> <xsl: otherwise> <xsl: value-of select=". "/><xsl: text> </xsl: text><xsl: value-of select="@Scientific_Name"/> </xsl: otherwise> </xsl: choose> </xsl: template> </xsl: stylesheet>
A bit of Birds. out <? xml version="1. 0" encoding="UTF-8"? > <Bird. Info> Order is: TINAMIFORMES Family is: TINAMIDAE Great Tinamou. Tinamus major Highland Tinamou. Nothocercus Little Tinamou. Crypturellus soui Thicket Tinamou. Crypturellus cinnamomeus Slaty-breasted Tinamou. Crypturellus boucardi Choco Tinamou. Crypturellus kerriae Order is: GAVIIFORMES Family is: GAVIIDAE Red-throated Loon. Gavia stellata Arctic Loon. Gavia arctica Pacific Loon. Gavia pacifica Common Loon. Gavia immer Yellow-billed Loon. Gavia adamsii Order is: PODICIPEDIFORMES Family is: PODICIPEDIDAE Least Grebe. Tachybaptus dominicus Pied-billed Grebe. Podilymbus podiceps Atitlan Grebe. Horned Grebe. Red-necked Grebe. Eared Grebe. Western Grebe. Clark's Grebe.
Piping xsl output to output etc • Compile pipe. java: javac c: xalan-j-currentbinxalan-j_2_6_0samplesPipe. java • Run pipe (copy xml &xsl files to working directory first): java -classpath C: xalan-j-current-binxalan -j_2_6_0binxalan. jar; C: xalan-j-currentbinxalan-j_2_6_0binxerces. Impl. jar; C: xalan-jcurrent-binxalanj_2_6_0samplesSimple. Transform
Part of Birds. out from xsl piping <? xml version="1. 0" encoding="UTF-8"? > <Bird. Info> Order is: TINAMIFORMES Family is: TINAMIDAE Great Tinamou. Tinamus major Highland Tinamou. Nothocercus Little Tinamou. Crypturellus soui Thicket Tinamou. Crypturellus cinnamomeus Slaty-breasted Tinamou. Crypturellus boucardi Choco Tinamou. Crypturellus kerriae Order is: GAVIIFORMES Family is: GAVIIDAE Red-throated Loon. Gavia stellata Arctic Loon. Gavia arctica Pacific Loon. Gavia pacifica Common Loon. Gavia immer Yellow-billed Loon. Gavia adamsii Order is: PODICIPEDIFORMES Family is: PODICIPEDIDAE Least Grebe. Tachybaptus dominicus Pied-billed Grebe. Podilymbus podiceps Atitlan Grebe. Horned Grebe. Red-necked Grebe. Eared Grebe. Western Grebe. Clark's Grebe.
A sample batch file • The examples in Xalan have already been compiled and the jar file xalansamples in the xalanbin directory contains the executables. The following batch file (Simple. Transform. bat) runs from java bin: set PATH=%PATH%; C: Progra~1Javajdk 15. 0_0bin set CLASSPATH=%CLASSPATH%; c: xerces 1_2_0xerces. jar; c: xerces-1_2_0xerces. Samples. jar set CLASSPATH=%CLASSPATH%; c: xalan-j-currentbinxalan-j_2_6_0binxalan. jar; c: xalan-j-currentbinxalan-j_2_6_0binxalansamples. jar cd c: xalan-j-current-binxalanj_2_6_0samplesSimple. Transform java Simple. Transform
JDOM distribution comes with some xsl samples, too
Batch file • Batch file contents: java org. apache. xalan. xslt. Process -INDENT 3 -IN catalog. xml -XSL catalog. xsl -OUT output. html • DOS window: c: >java org. apache. xalan. xslt. Process -INDENT 3 -IN catalog. xml XSL catalog. xs l -OUT output. html
A little of the xml file (entire file in slide notes) <!-A simple XML file from Elliotte Rusty Harold's talk at SD 2000 East http: //www. ibiblio. org/xml/slides/sd 2000 east/xslt/ --> <catalog> <category> Small chamber ensembles - 2 -4 Players by New York Women Composers </category> <cataloging_info> <abstract>Compositions by the members of New York Women Composers</abstract> <keyword>music publishing</keyword> <keyword>scores</keyword> <keyword>women composers</keyword> <keyword>New York</keyword> </cataloging_info> <last_updated>July 28, 1999</last_updated> <copyright>1999 New York Women Composers</copyright> <maintainer email="elharo@metalab. unc. edu" url="http: //www. macfaq. com/personal. html"> <name> <first_name>Elliotte</first_name> <middle_name>Rusty</middle_name> <last_name>Harold</last_name> </maintainer>
A little of the xsl file <? xml version="1. 0" encoding="UTF-8"? > <!-A simple XSL file from Elliotte Rusty Harold's talk at SD 2000 East http: //www. ibiblio. org/xml/slides/sd 2000 east/xslt/ --> <xsl: stylesheet version="1. 0" xmlns: xsl="http: //www. w 3. org/1999/XSL/Transform"> <xsl: template match="/"> <html> <xsl: apply-templates select="catalog"/> </html> </xsl: template> <xsl: template match="catalog"> <head> <title><xsl: value-of select="category"/></title> </head> <body> <h 1><xsl: value-of select="category"/></h 1> <xsl: apply-templates select="composition"/> <hr/> Copyright <xsl: value-of select="copyright"/><br/> Last Modified: <xsl: value-of select="last_updated"/> </body> </xsl: template>
A little of the output. html <html> <head> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title> Small chamber ensembles - 2 -4 Players by New York Women Composers </title> </head> <body> <h 1> Small chamber ensembles - 2 -4 Players by New York Women Composers </h 1> <h 3>Trio for Flute, Viola and Harp</h 3> <ul> <li>(1994)</li> <li>13'38"</li> <li>fl, hp, vla</li> <li>Theodore Presser</li> </ul> <p> Premiered at Queens College in April, 1996 by Sue Ann Kahn, Christine Ims, and Susan Jolles. In 3 movements : mvt. 1: 5: 01 mvt. 2: 4: 11 mvt. 3: 4: 26 </p> <h 3>Charmonium</h 3> <ul> <li>(1991)</li> <li>9'</li> <li>2 vln, vla, vc</li> <li></li> </ul> <p>
- Xml
- What does xsl stand for
- Xslt stands for _____.
- Xslfo
- Xsl processor
- Language definition
- Xsl
- Esslii
- Pacman vs ghost
- Romeo and juliet prologue paraphrase
- Transverse lie definition
- All good gifts around us are sent from heaven above
- Climax of jack and the beanstalk
- Romeo and juliet prologue annotations
- Conclusion paragraph formula
- Romeo and juliet body paragraph
- Thermochemistry intro and joule conversions
- Titles for conclusions
- National literacy and numeracy learning progressions
- Vlan spanning
- Version control systems industry
- Ursv2
- Uft version history
- Triangle congruence review maze
- Hebrews 4 12 amplified version
- Apostles creed methodist
- Tortoise svn tutorial
- Risk student version
- Software numbering conventions
- Sac ciudadano
- Tommy rea
- A revised version of little red riding hood answers
- El autor secundario de la biblia es
- Nhdplus version 2
- Spss 13 download
- Powerpoint version control
- Eviews
- Cfs version 2
- Version control branching
- Affinity trial stroke
- Togaf history
- Climate forecast system version 2
- Fhir version history
- Snow white and the seven dwarfs gender roles
- Oracle apex latest version features
- Exemple d'analyse environnementale iso 14001 version 2015
- What is mayella's version of what happened
- Csscr
- Msdp myanmar
- Alienbrain version control
- Aws signature version 4
- Family economics & financial education
- Esisse
- D365 one version
- Digital literacy standard curriculum version 4
- Data governance body of knowledge
- Cvs versioning system
- Management review iso 9001 version 2015 muster
- The rpc server is unavailable - error code:6ba
- Windows 7 embedded iso
- Promotion request windchill
- Mille feuilles 3 digitale schülermaterialien
- Windows longhorn
- Maximo roadmap