XML Transformations Anitha Reddy
Agenda URI,URL,URN Overview XSL & co XPath  XSLT Language XSL-FO AltovaXML Spy Demo
URI a  Uniform Resource Identifier  ( URI ), is a compact  string  of  characters  used to  identify  or  name  a  resource . The main purpose of this identification is to enable interaction with representations of the resource over a network, typically the  World Wide Web , using specific  protocols .   A  URI   may  be classified as a locator (URL) or a name (URN) or both.  A  Uniform Resource Name  (URN) is like a person's name, while a  Uniform Resource Locator  (URL) is like their street address  Syntax:  The URI syntax is essentially a  URI scheme  name like " HTTP ", " FTP ", " mailto ", etc., followed by a  colon  character, and then a scheme-specific part.
Overview XSL:  xml-based Stylesheet Language Xpath:  a language for navigating in XML documents XQuery:   the  language for querying XML data  XLink:  defines a standard way of creating hyperlinks in XML documents. Xpointer:  allows the hyperlinks to point to more specific parts (fragments) in the XML document. XSL-FO XSL FAMILY
XSL & co It started with XSL and ended up with XSLT, XPath, and XSL-FO.  XSL consists of three parts: XSLT - a language for transforming XML documents XPath - a language for navigating in XML documents XSL-FO - a language for formatting XML documents XSLT became a W3C Recommendation 16. November 1999
XSLT Advantages & Disadvantages Advantages: Easy display formatted XML data in browser. Easier to modify when XML data format changes than to modify DOM and SAX parsing code. Can be used with database queries that return XML. Disadvantages: Memory intensive, performance hit. Difficult to implement complex business rules. Have to learn new language.
XSLT and Java JDK 1.4 contains all necessary classes See  javax.xml.transform  package. Lower versions require downloading XSLT processor and SAX parser.  XSLT Processors Apache Xalan http://xml.apache.org/ xalan SAXON http://saxon.sourceforge.net Microsoft’s XML Parser 4.0 (MSXML) http://www.microsoft.com/xml
XML Transformation Example hello.xml hello.xsl HTML, XML etc
How XSLT works The XML text document is read in and stored as a  tree  of nodes The  <xsl:template match=&quot;/&quot;>  template is used to select the entire tree The rules within the template are applied to the matching nodes, thus changing the structure of the XML tree If there are other templates, they must be  called  explicitly from the main template Unmatched parts of the XML tree are not changed After the template is applied, the tree is written out again as a text document
<?xml version=&quot;1.0&quot; ?> <!-- hello.xml --> <?xml:stylesheet type=&quot;text/xsl&quot; href=&quot;hello.xsl&quot;?> <myMessage> <message> Hello XSLT! </message> </myMessage> <html> <body> <h1> Hello XSLT! </h1> </body> </html> <?xml version=&quot;1.0&quot; ?> <!-- hello.xsl --> <xsl:stylesheet version=&quot;1.0&quot;  xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;> <xsl:template match=&quot; myMessage &quot;> <html><body> <h1> <xsl:value-of select=&quot;message&quot;/> </h1> </body></html> </xsl:template> </xsl:stylesheet>
Transform.java import  javax.xml.transform.*; java Transform hello.xsl hello.xml File stylesheet = new File(argv[0]); File datafile = new File(argv[1]); TransformerFactory tFactory = TransformerFactory.newInstance(); StreamSource stylesource = new StreamSource(stylesheet); Transformer transformer = tFactory.newTransformer(stylesource); StreamSource source = new StreamSource(datafile); StreamResult result = new StreamResult(System.out); transformer.transform(source, result);  // Produce output to console Any InputStream / String Any OutputStream / String
XPath XPath is an expression language used to: Find nodes and attributes (location paths) in the XML file Test boolean conditions Manipulate strings Perform numerical calculations
Location Paths Match root node   <xsl:template match=“ / ”/>   …   </xsl:template> /AAA:  Select the root element AAA        <AAA>             <BBB/>            <CCC/>            <EEE/>        </AAA>   /AAA/CCC:  Select all elements CCC which are children of the root element AAA       <AAA>             <CCC/>             <BBB/>            <DDD/>              <CCC/>        </AAA>
Location Paths contd.. Use // to indicate zero or more elements may occur between slashes //BBB : Select all elements BBB       <AAA>             <BBB/>             <CCC/>           <DDD>                  <BBB/>            </DDD>            <CCC>                 <DDD>                       <BBB/>                      <BBB/>                  </DDD>            </CCC>       </AAA>  <xsl:template match=“ order//item ”/>  <!-- Match all  item  elements that are   descendants of  order . --> </xsl:template>
Location Paths contd.. Match a specific element Use […] as a predicate filter to select a particular element /AAA/BBB[1] : Select the first BBB child of element AAA        <AAA>             <BBB/>             <BBB/>            <BBB/>            <BBB/>       </AAA>   / AAA/BBB[last()] :   Select the last BBB child of element AAA    <AAA>              <BBB/>            <BBB/>             <BBB/> </AAA>
Location Paths contd.. Match a specific attribute:  Use @ attribute  to select a particular attribute //BBB[@name] : Select BBB elements which have attribute name       <AAA>            <BBB id = &quot;b1&quot;/>            <BBB id = &quot;b2&quot;/>            < BBB  name = &quot;bbb&quot;/>            <BBB/>       </AAA>   //BBB[not(@*)] : Select BBB elements without an attribute       <AAA>            <BBB id = &quot;b1&quot;/>            <BBB name = &quot;bbb&quot;/>             <BBB/>        </AAA>  //BBB[@name='b1'] : Select BBB elements which have attribute name with value 'b1'       <AAA>            < BBB  id = &quot;b1&quot;/>            <BBB name = &quot; bbb &quot;/>       </AAA>
Location Paths contd.. /AAA/BBB/descendant::*  Select all descendants of /AAA/BBB        <AAA>            <BBB>                  <DDD>                      <CCC>                           <DDD/>                           <EEE/>                      </CCC>                 </DDD>            </BBB>            <CCC>                 <DDD/>            </CCC>       </AAA>
Location Paths contd.. The ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always include the root node, unless the context node is the root node.  /AAA/BBB/DDD/CCC/EEE/ancestor::*  Select all elements given in this absolute path      <AAA>            <BBB>                 <DDD>                      <CCC>                           <DDD/>                           <EEE/>                       </CCC>                 </DDD>            </BBB>            <CCC>                 <DDD>                      <EEE>                      </EEE>                 </DDD>            </CCC>        </AAA>
Location Paths contd.. The ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always include the root node, unless the context node is the root node.  /AAA/BBB/following-sibling::*  The following-sibling axis contains all the following siblings of the context node.        <AAA>            <BBB>                 <CCC/>                 <DDD/>            </BBB>             <XXX>                  <DDD>                      <DDD/>                      <FFF/>                </DDD>             </XXX>              <CCC>                  <DDD/>             </CCC>        </AAA>
Location Paths contd.. The ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always include the root node, unless the context node is the root node.  //ZZZ/following::*  The following axis contains all nodes in the same document as the context node that are after the context node in document order, excluding any descendants and excluding attribute nodes and namespace nodes. .        <AAA>            <BBB>                 <ZZZ>                      <DDD/>                                    </ZZZ>                  <FFF>                      <GGG/>                 </FFF>             </BBB>             <XXX>                 <FFF/>             </XXX>                </AAA>
The ancestor, descendant, following, preceding and self axes partition a document (ignoring attribute and namespace nodes): they do not overlap and together they contain all the nodes in the document.          <AAA>              <BBB>                 <CCC/>                 <ZZZ/>            </BBB>              <XXX>                 <DDD>                       <EEE/>                        <FFF>                             <HHH/>                            <GGG>                                  <JJJ>                                     <QQQ/>                                </JJJ>                                <JJJ/>                            </GGG>                            <HHH/>                        </FFF>                 </DDD>            </XXX>              <CCC>                 <DDD/>            </CCC>        </AAA>   Location Paths contd.. //GGG/ancestor::*   //GGG/descendant::*  //GGG/following::*  //GGG/preceding::*  //GGG/self::*
Xpath Functions name()  returns name of the element  //*[name()='BBB']:  Select all elements with name BBB, equivalent with //BBB  starts-with(arg1,arg2)  function returns true if the first argument string starts with the second argument string //*[starts-with(name(),'B')]:  Select all elements name of which starts with letter B  Contains(arg1,arg2)  function returns true if the first argument string contains the second argument string //*[contains(name(),'C')]:  Select all elements name of which contain letter C  String-length(arg1) function returns the number of characters in the string //*[string-length(name()) = 3] Select elements with three-letter name        <AAA>            <Q/>            <SSSS/>            <BB/>             <CCC/>             <DDDDDDDD/>            <EEEE/>        </AAA>
XSLT Stylesheet Elements Matching and selection templates xsl:template xsl:apply-templates xsl:value-of Branching elements xsl:for-each xsl:if xsl:choose
XSLT template Element xsl:template match=“ XPath ” Defines a template rule for producing output Is applied only to nodes that match the pattern Invoked by using  <xsl:apply-templates/> “ .” selects the text value of the current node <xsl:template match=&quot;/&quot;> <html><body> <xsl:apply-templates/> </body></html> </xsl:template> <xsl:template match=“name&quot;> Your name is <xsl:value-of select=“.&quot;/> </xsl:template>
XSLT value-of Element xsl:value-of select=“ expression ” Evaluates the  expression  as a string and outputs the result Applied only to the first match <name prefix=“Mr.”>John Doe</name> _________________________________________________ <xsl:template match=“name&quot;> Your name is  <xsl:value-of select=“@prefix&quot;/> <xsl:value-of select=“.&quot;/> </xsl:template>
XSLT for-each Element xsl:for-each select=“ expression ” Processes each node selected by the XPath expression(looping) Applied only to the first match “ .” selects the text value of the current node <class> <student>Kim Smith</student> <student>Jack Black</student> </class> _______________________________________________________ <xsl:template match=“class&quot;> <xsl:for-each select=“student&quot;>    <b><xsl:value-of select=“.&quot;/></b> </xsl:for-each> </xsl:template>
XSLT if Element xsl:if test=“ expression ” Evaluates the  expression  and if true applies the template No if-else, use choose instead <xsl:template match=“class&quot;> <!-- Select the first node in the set. --> <xsl:if select=“position() = first()&quot;>    <b><xsl:value-of select=“.&quot;/></b> </xsl:if> </xsl:template>
XSLT choose Element xsl:choose   Selects any number of alternatives Use instead of if-else, or switch statement used in other programming languages <xsl:choose> <xsl:when test=“not(text())&quot;>    Missing value! </xsl:when> <xsl:otherwise>   <xsl:value-of select=“.”/> </xsl:otherwise> </xsl:choose>
XSL-FO
What is XSL-FO XSL-FO is a language for formatting XML data XSL-FO stands for Extensible Stylesheet Language Formatting Objects XSL-FO is a W3C Recommendation XSL-FO is now formally named XSL(Styling is both about  transforming  and  formatting  information. ) XSL-FO is an XML-based markup language describing the formatting of XML data for output to screen, paper or other media XSL-FO documents are XML files with output information
XSL-FO structure FO document instances represent structures of composed pages: Page sequences Page regions Flows Blocks Inlines Etc. FO implementations interpret FO instances to produce final renditions (e.g., pages)
XSL-FO document  <?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?> <fo:root xmlns:fo=&quot;http://www.w3.org/1999/XSL/Format&quot;>  <fo:layout-master-set> <fo:simple-page-master master-name=&quot;A4&quot;> <!-- Page template goes here --> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference=&quot;A4&quot;> <!-- Page content goes here --> </fo:page-sequence> </fo:root>
Current FO implementations Open Source/Freeware Page regions Apache FOP Part of Apache project Most complete open source implementation Currently being rearchitected to be more flexible and functional Pure Java PassiveTeX Implemented in TeX Advertised as experimental IBM XML FO Composer (XFC) Lacks many key features Product direction/level of support unclear SUN FO Implementation (announced at this conference) Others (see www.w3.org/Style/XSL )
XSL-FO Production process XSLT to  FO FO Impl. <mydoc> … <p> Hello </p> … </mydoc> Source XML Document <fo:root> … <fo:block> Hello </fo:block> … </fo:root> Generated FO Instance Hello 1 Rendered Pages
AltovaXML Spy Altova XMLSpy®   2008  is a comprehensive IDE for developing XML projects The Enterprise Edition provides an efficient and flexible environment for creating and editing DTDs, XML Schemas, XML files, and XSLT stylesheets. Features Well-formedness checking and built-in validator  Schema editing and management  Built-in XSLT 1.0 and XSLT 2.0 processors XSLT Debugger for XSLT 1.0 and XSLT 2.0 Transformations of XML documents Comparing XML files   Support for XInclude and XPointer
XMLSPY in action
References Xpath-  http://www.zvon.org/xxl/XPathTutorial/Output/example1.html XMLSpy Tutorial http://www.altova.com/manual2008/XMLSpy/spyenterprise/index.html?xmlspytutorial. htm
A Q &

XMLT

  • 1.
  • 2.
    Agenda URI,URL,URN OverviewXSL & co XPath XSLT Language XSL-FO AltovaXML Spy Demo
  • 3.
    URI a Uniform Resource Identifier ( URI ), is a compact string of characters used to identify or name a resource . The main purpose of this identification is to enable interaction with representations of the resource over a network, typically the World Wide Web , using specific protocols . A URI may be classified as a locator (URL) or a name (URN) or both. A Uniform Resource Name (URN) is like a person's name, while a Uniform Resource Locator (URL) is like their street address Syntax: The URI syntax is essentially a URI scheme name like &quot; HTTP &quot;, &quot; FTP &quot;, &quot; mailto &quot;, etc., followed by a colon character, and then a scheme-specific part.
  • 4.
    Overview XSL: xml-based Stylesheet Language Xpath: a language for navigating in XML documents XQuery: the language for querying XML data XLink: defines a standard way of creating hyperlinks in XML documents. Xpointer: allows the hyperlinks to point to more specific parts (fragments) in the XML document. XSL-FO XSL FAMILY
  • 5.
    XSL & coIt started with XSL and ended up with XSLT, XPath, and XSL-FO. XSL consists of three parts: XSLT - a language for transforming XML documents XPath - a language for navigating in XML documents XSL-FO - a language for formatting XML documents XSLT became a W3C Recommendation 16. November 1999
  • 6.
    XSLT Advantages &Disadvantages Advantages: Easy display formatted XML data in browser. Easier to modify when XML data format changes than to modify DOM and SAX parsing code. Can be used with database queries that return XML. Disadvantages: Memory intensive, performance hit. Difficult to implement complex business rules. Have to learn new language.
  • 7.
    XSLT and JavaJDK 1.4 contains all necessary classes See javax.xml.transform package. Lower versions require downloading XSLT processor and SAX parser. XSLT Processors Apache Xalan http://xml.apache.org/ xalan SAXON http://saxon.sourceforge.net Microsoft’s XML Parser 4.0 (MSXML) http://www.microsoft.com/xml
  • 8.
    XML Transformation Examplehello.xml hello.xsl HTML, XML etc
  • 9.
    How XSLT worksThe XML text document is read in and stored as a tree of nodes The <xsl:template match=&quot;/&quot;> template is used to select the entire tree The rules within the template are applied to the matching nodes, thus changing the structure of the XML tree If there are other templates, they must be called explicitly from the main template Unmatched parts of the XML tree are not changed After the template is applied, the tree is written out again as a text document
  • 10.
    <?xml version=&quot;1.0&quot; ?><!-- hello.xml --> <?xml:stylesheet type=&quot;text/xsl&quot; href=&quot;hello.xsl&quot;?> <myMessage> <message> Hello XSLT! </message> </myMessage> <html> <body> <h1> Hello XSLT! </h1> </body> </html> <?xml version=&quot;1.0&quot; ?> <!-- hello.xsl --> <xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;> <xsl:template match=&quot; myMessage &quot;> <html><body> <h1> <xsl:value-of select=&quot;message&quot;/> </h1> </body></html> </xsl:template> </xsl:stylesheet>
  • 11.
    Transform.java import javax.xml.transform.*; java Transform hello.xsl hello.xml File stylesheet = new File(argv[0]); File datafile = new File(argv[1]); TransformerFactory tFactory = TransformerFactory.newInstance(); StreamSource stylesource = new StreamSource(stylesheet); Transformer transformer = tFactory.newTransformer(stylesource); StreamSource source = new StreamSource(datafile); StreamResult result = new StreamResult(System.out); transformer.transform(source, result); // Produce output to console Any InputStream / String Any OutputStream / String
  • 12.
    XPath XPath isan expression language used to: Find nodes and attributes (location paths) in the XML file Test boolean conditions Manipulate strings Perform numerical calculations
  • 13.
    Location Paths Matchroot node <xsl:template match=“ / ”/> … </xsl:template> /AAA: Select the root element AAA       <AAA>           <BBB/>           <CCC/>           <EEE/>       </AAA> /AAA/CCC: Select all elements CCC which are children of the root element AAA      <AAA>            <CCC/>           <BBB/>           <DDD/>             <CCC/>      </AAA>
  • 14.
    Location Paths contd..Use // to indicate zero or more elements may occur between slashes //BBB : Select all elements BBB      <AAA>            <BBB/>           <CCC/>          <DDD>                 <BBB/>           </DDD>           <CCC>                <DDD>                      <BBB/>                     <BBB/>                </DDD>           </CCC>      </AAA> <xsl:template match=“ order//item ”/> <!-- Match all item elements that are descendants of order . --> </xsl:template>
  • 15.
    Location Paths contd..Match a specific element Use […] as a predicate filter to select a particular element /AAA/BBB[1] : Select the first BBB child of element AAA       <AAA>            <BBB/>           <BBB/>           <BBB/>           <BBB/>      </AAA> / AAA/BBB[last()] : Select the last BBB child of element AAA <AAA>             <BBB/>           <BBB/>            <BBB/> </AAA>
  • 16.
    Location Paths contd..Match a specific attribute: Use @ attribute to select a particular attribute //BBB[@name] : Select BBB elements which have attribute name      <AAA>           <BBB id = &quot;b1&quot;/>           <BBB id = &quot;b2&quot;/>           < BBB name = &quot;bbb&quot;/>           <BBB/>      </AAA> //BBB[not(@*)] : Select BBB elements without an attribute      <AAA>           <BBB id = &quot;b1&quot;/>           <BBB name = &quot;bbb&quot;/>            <BBB/>      </AAA> //BBB[@name='b1'] : Select BBB elements which have attribute name with value 'b1'      <AAA>           < BBB id = &quot;b1&quot;/>           <BBB name = &quot; bbb &quot;/>      </AAA>
  • 17.
    Location Paths contd../AAA/BBB/descendant::* Select all descendants of /AAA/BBB       <AAA>           <BBB>                 <DDD>                     <CCC>                          <DDD/>                          <EEE/>                     </CCC>                </DDD>           </BBB>           <CCC>                <DDD/>           </CCC>      </AAA>
  • 18.
    Location Paths contd..The ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always include the root node, unless the context node is the root node. /AAA/BBB/DDD/CCC/EEE/ancestor::* Select all elements given in this absolute path     <AAA>           <BBB>                <DDD>                     <CCC>                          <DDD/>                          <EEE/>                      </CCC>                </DDD>           </BBB>           <CCC>                <DDD>                     <EEE>                     </EEE>                </DDD>           </CCC>       </AAA>
  • 19.
    Location Paths contd..The ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always include the root node, unless the context node is the root node. /AAA/BBB/following-sibling::* The following-sibling axis contains all the following siblings of the context node.       <AAA>           <BBB>                <CCC/>                <DDD/>           </BBB>            <XXX>                <DDD>                     <DDD/>                     <FFF/>                </DDD>            </XXX>            <CCC>                <DDD/>            </CCC>      </AAA>
  • 20.
    Location Paths contd..The ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always include the root node, unless the context node is the root node. //ZZZ/following::* The following axis contains all nodes in the same document as the context node that are after the context node in document order, excluding any descendants and excluding attribute nodes and namespace nodes. .       <AAA>           <BBB>                <ZZZ>                     <DDD/>                                    </ZZZ>                 <FFF>                     <GGG/>                </FFF>           </BBB>            <XXX>                <FFF/>            </XXX>                </AAA>
  • 21.
    The ancestor, descendant,following, preceding and self axes partition a document (ignoring attribute and namespace nodes): they do not overlap and together they contain all the nodes in the document.        <AAA>            <BBB>                <CCC/>                <ZZZ/>           </BBB>            <XXX>                <DDD>                      <EEE/>                      <FFF>                           <HHH/>                          <GGG>                                 <JJJ>                                    <QQQ/>                               </JJJ>                               <JJJ/>                          </GGG>                           <HHH/>                      </FFF>                </DDD>           </XXX>            <CCC>                <DDD/>           </CCC>       </AAA> Location Paths contd.. //GGG/ancestor::* //GGG/descendant::* //GGG/following::* //GGG/preceding::* //GGG/self::*
  • 22.
    Xpath Functions name() returns name of the element //*[name()='BBB']: Select all elements with name BBB, equivalent with //BBB starts-with(arg1,arg2) function returns true if the first argument string starts with the second argument string //*[starts-with(name(),'B')]: Select all elements name of which starts with letter B Contains(arg1,arg2) function returns true if the first argument string contains the second argument string //*[contains(name(),'C')]: Select all elements name of which contain letter C String-length(arg1) function returns the number of characters in the string //*[string-length(name()) = 3] Select elements with three-letter name       <AAA>           <Q/>           <SSSS/>           <BB/>            <CCC/>           <DDDDDDDD/>           <EEEE/>       </AAA>
  • 23.
    XSLT Stylesheet ElementsMatching and selection templates xsl:template xsl:apply-templates xsl:value-of Branching elements xsl:for-each xsl:if xsl:choose
  • 24.
    XSLT template Elementxsl:template match=“ XPath ” Defines a template rule for producing output Is applied only to nodes that match the pattern Invoked by using <xsl:apply-templates/> “ .” selects the text value of the current node <xsl:template match=&quot;/&quot;> <html><body> <xsl:apply-templates/> </body></html> </xsl:template> <xsl:template match=“name&quot;> Your name is <xsl:value-of select=“.&quot;/> </xsl:template>
  • 25.
    XSLT value-of Elementxsl:value-of select=“ expression ” Evaluates the expression as a string and outputs the result Applied only to the first match <name prefix=“Mr.”>John Doe</name> _________________________________________________ <xsl:template match=“name&quot;> Your name is <xsl:value-of select=“@prefix&quot;/> <xsl:value-of select=“.&quot;/> </xsl:template>
  • 26.
    XSLT for-each Elementxsl:for-each select=“ expression ” Processes each node selected by the XPath expression(looping) Applied only to the first match “ .” selects the text value of the current node <class> <student>Kim Smith</student> <student>Jack Black</student> </class> _______________________________________________________ <xsl:template match=“class&quot;> <xsl:for-each select=“student&quot;> <b><xsl:value-of select=“.&quot;/></b> </xsl:for-each> </xsl:template>
  • 27.
    XSLT if Elementxsl:if test=“ expression ” Evaluates the expression and if true applies the template No if-else, use choose instead <xsl:template match=“class&quot;> <!-- Select the first node in the set. --> <xsl:if select=“position() = first()&quot;> <b><xsl:value-of select=“.&quot;/></b> </xsl:if> </xsl:template>
  • 28.
    XSLT choose Elementxsl:choose Selects any number of alternatives Use instead of if-else, or switch statement used in other programming languages <xsl:choose> <xsl:when test=“not(text())&quot;> Missing value! </xsl:when> <xsl:otherwise> <xsl:value-of select=“.”/> </xsl:otherwise> </xsl:choose>
  • 29.
  • 30.
    What is XSL-FOXSL-FO is a language for formatting XML data XSL-FO stands for Extensible Stylesheet Language Formatting Objects XSL-FO is a W3C Recommendation XSL-FO is now formally named XSL(Styling is both about transforming and formatting information. ) XSL-FO is an XML-based markup language describing the formatting of XML data for output to screen, paper or other media XSL-FO documents are XML files with output information
  • 31.
    XSL-FO structure FOdocument instances represent structures of composed pages: Page sequences Page regions Flows Blocks Inlines Etc. FO implementations interpret FO instances to produce final renditions (e.g., pages)
  • 32.
    XSL-FO document <?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?> <fo:root xmlns:fo=&quot;http://www.w3.org/1999/XSL/Format&quot;> <fo:layout-master-set> <fo:simple-page-master master-name=&quot;A4&quot;> <!-- Page template goes here --> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference=&quot;A4&quot;> <!-- Page content goes here --> </fo:page-sequence> </fo:root>
  • 33.
    Current FO implementationsOpen Source/Freeware Page regions Apache FOP Part of Apache project Most complete open source implementation Currently being rearchitected to be more flexible and functional Pure Java PassiveTeX Implemented in TeX Advertised as experimental IBM XML FO Composer (XFC) Lacks many key features Product direction/level of support unclear SUN FO Implementation (announced at this conference) Others (see www.w3.org/Style/XSL )
  • 34.
    XSL-FO Production processXSLT to FO FO Impl. <mydoc> … <p> Hello </p> … </mydoc> Source XML Document <fo:root> … <fo:block> Hello </fo:block> … </fo:root> Generated FO Instance Hello 1 Rendered Pages
  • 35.
    AltovaXML Spy AltovaXMLSpy® 2008 is a comprehensive IDE for developing XML projects The Enterprise Edition provides an efficient and flexible environment for creating and editing DTDs, XML Schemas, XML files, and XSLT stylesheets. Features Well-formedness checking and built-in validator Schema editing and management Built-in XSLT 1.0 and XSLT 2.0 processors XSLT Debugger for XSLT 1.0 and XSLT 2.0 Transformations of XML documents Comparing XML files Support for XInclude and XPointer
  • 36.
  • 37.
    References Xpath- http://www.zvon.org/xxl/XPathTutorial/Output/example1.html XMLSpy Tutorial http://www.altova.com/manual2008/XMLSpy/spyenterprise/index.html?xmlspytutorial. htm
  • 38.