EVALUATION COPY. Contents

Size: px
Start display at page:

Download "EVALUATION COPY. Contents"

Transcription

1 Contents Chapter 1 - Course Introduction... 7 Course Objectives... 8 Course Overview Using the Workbook Suggested References Chapter 2 - Defining New Types Using Schemas Substitution Groups All and Choice Elements Simple Type Restrictions Pattern and Enumeration Facets Complex Types and Extensions Complex Types and Restrictions The final Attribute Labs Chapter 3 - Additional Schema Elements Uniqueness Keys and Keyref Groups Attribute Groups redefine Allowing Any Content Mixed Content Documentation Schemas Labs Chapter 4 - Using XML Schema with Namespaces Qualified and Unqualified XML Associating Qualified XML with a Schema Associating a Schema with a Namespace Controlling Element and Attribute Qualification Merging Schema with the Same Namespace Merging Schemas with Different Namespaces ITCourseware, LLC Rev Page iii

2 Labs Chapter 5 - Generating Output with XSLT Output Methods HTML Output Plain Text Output XML Output xsl:element and xsl:attribute Attribute Value Templates xsl:attribute-set Text, Processing-Instructions, and Comments Working with Namespaces Labs Chapter 6 - Using XPath and XSLT Functions XPath Datatypes and Functions Node Test Functions Node Set Functions Boolean Functions String Functions Number Functions XSLT Functions The document() Function xsl:key and the key() Function Labs Chapter 7 - Advanced XSLT Copying Elements Numbering Variables Parameters Using Other Stylesheets Apply-imports Template Rule Conflicts Extensions Labs Chapter 8 - XSLT and XPATH 2.0 New Features XSLT 2.0 Grouping Elements and Functions Page iv Rev ITCourseware, LLC

3 User-Defined XSLT Functions Multiple Output and XHTML Documents Temporary Trees Sequences Types Stylesheets That Are Schema-Aware Character Mapping Regular Expressions Labs Appendix A - Introduction to XQuery What is XQuery? doc() Function XQuery Datatypes XQuery Expressions XQuery Prolog Modules Conditional Expressions Iteration and FLWOR Built-in Functions User-Defined Functions Labs Appendix B - XSL Formatting Objects What is XSL? XSL-FO Overview Types of Objects Defining Page Masters Setting Up the Flow Block-Level vs. Inline-Level Objects Lists Tables Out-of-Line Objects Solutions Index ITCourseware, LLC Rev Page v

4 Page vi Rev ITCourseware, LLC

5 Chapter 1 Course Introduction Chapter 1 - Course Introduction 2013 ITCourseware, LLC Rev Page 7

6 Course Objectives Reuse XML Schema content using features such as restriction, extension, and redefinition. Ensure element or attribute uniqueness with XML Schema. Transform XSLT stylesheets to text, HTML, and XML output. Call various XPath and XSLT functions. Merge XSLT stylesheets using include and import syntax. Use XSLT and XPath 2.0 elements and functions. Page 8 Rev ITCourseware, LLC

7 Chapter 1 Course Introduction 2013 ITCourseware, LLC Rev Page 9

8 Course Overview Audience: XML developers that need to use some of the advanced features of XML. Prerequisites: Introduction to XML. Some XML development experience. Classroom Environment: Workstation per student with an XML Schema validator and XSLT processor installed. Page 10 Rev ITCourseware, LLC

9 Chapter 1 Course Introduction Using the Workbook This workbook design is based on a page-pair, consisting of a Topic page and a Support page. When you lay the workbook open flat, the Topic page is on the left and the Support page is on the right. The Topic page contains the points to be discussed in class. The Support page has code examples, diagrams, screen shots and additional information. Hands On sections provide opportunities for practical application of key concepts. Try It and Investigate sections help direct individual discovery. In addition, there is an index for quick look-up. Printed lab solutions are in the back of the book as well as on-line if you need a little help. The Topic page provides the main topics for classroom discussion. The Support page has additional information, examples and suggestions. Java Servlets Chapter 2 Servlet Basics The Servlet Life Cycle The servlet container controls the life cycle of the servlet. When the first request is received, the container loads the servlet class and calls the init() method. Topics are organized into first (), second ( ) and For every request, the container uses a separate thread to call the service() method. third ( ) level When points. the servlet is unloaded, the container calls the destroy() method. As with Java s finalize() method, don t count on this being called. Override one of the init() methods for one-time initializations, instead of using a constructor. The simplest form takes no parameters. Hands On: Add an init() method to your Today servlet that initializes a bornon date, then print the bornon date along with the current date: Today.java... Code examples are in a fixed font and shaded. The on-line file name is listed above the shaded area. public class Today extends GenericServlet { private Date bornon; public void service(servletrequest request, ServletResponse response) throws ServletException, IOException {... // Write the document out.println("this servlet was born on " + bornon.tostring()); out.println("it is now " + today.tostring()); } public void init() { bornon = new Date(); } The init() method is called when the servlet is } loaded into the container. Callout boxes point out important parts of the example code. public void init() {...} If you need to know container-specific configuration information, use the other version. public void init(servletconfig config) {... Whenever you use the ServletConfig approach, always call the superclass method, which performs additional initializations. super.init(config); Page 16 Rev ITCourseware, LLC Pages are numbered sequentially throughout the book, making lookup easy. Screen shots show examples of what you should see in class ITCourseware, LLC Rev Page ITCourseware, LLC Rev Page 11

10 Suggested References Benz, Brian and John Durant XML Programming Bible. John Wiley & Sons, Hoboken, NJ. ISBN Box, Don, Aaron Skonnard and John Lam Essential XML: Beyond Markup. Addison-Wesley, Reading, MA. ISBN Harold, Elliotte Rusty Effective XML. Addison-Wesley, Reading, MA. ISBN Harold, Elliotte Rusty XML 1.1 Bible. John Wiley & Sons, Hoboken, NJ. ISBN Harold, Elliotte Rusty and W. Scott Means XML in a Nutshell, 3rd Edition. O Reilly Media, Sebastopol, CA. ISBN Kay, Michael XSLT 2.0 and XPath 2.0 Programmer's Reference (Programmer to Programmer). Wrox Press, Chicago, IL. ISBN Skonnard, Aaron and Nartuib Gudgin Essential XML Quick Reference: A Programmer's Reference to XML, XPath, XSLT, XML Schema, SOAP, and More. Addison-Wesley Professional, Reading, MA. ISBN St. Laurent, Simon and Michael Fitzgerald XML Pocket Reference, 3rd Edition. O Reilly Media, Sebastopol, CA. ISBN Tidwell, Doug XSLT, 2nd Edition. O'Reilly Media, Sebastopol, CA. ISBN Walmsley, Priscilla Definitive XML Schema. Prentice Hall PTR, Upper Saddle River, NJ. ISBN Walmsley, Priscilla XQuery. O'Reilly Media, Sebastopol, CA. ISBN Page 12 Rev ITCourseware, LLC

11 Chapter 1 Course Introduction 2013 ITCourseware, LLC Rev Page 13

12 Page 14 Rev ITCourseware, LLC

13 Chapter 2 Defining New Types Using Schemas Chapter 2 - Defining New Types Using Schemas Objectives Define new types by restricting and extending previously defined types. Prevent custom defined types from being inherited by other types. Define elements that can be substituted for other elements. Allow elements to contain lists of values ITCourseware, LLC Rev Page 15

14 Substitution Groups Use the substitutiongroup attribute on xs:element to allow that element to substitute for another top-level element. Only top-level element declarations are allowed to contain the substitutiongroup attribute. Use the name of the target top-level element that this element can substitute for as the value of the substitutiongroup attribute. <xs:element name="fname" type="xs:string" /> <xs:element name="first" substititiongroup="fname" type="xs:string" /> The type of the substitute element must be the same as or derived from the type of the target element. You can exclude the type attribute on the substitute element if the type is the same as the target top-level element. <xs:element name="fname" type="xs:string" /> <xs:element name="first" substititiongroup="fname" /> Page 16 Rev ITCourseware, LLC

15 Chapter 2 Defining New Types Using Schemas purchase.xsd <xs:schema xmlns:xs=" <xs:element name="purchase" type="purchasetype" /> <xs:element name="mi" type="mitype"/> <xs:element name="nomiddleinit" substitutiongroup="mi" type="nomitype" /> <xs:complextype name="purchasetype"> <xs:sequence> <xs:element name="customer" type="custtype"/> <xs:element name="total" type="totaltype"/> <xs:element name="guarantee" type="yesnotype"/> <xs:element name="deliver" type="yesnotype"/> <xs:element name="discountcodes" type="discountlisttype" /> <xs:element name="payment" type="paymenttype" /> </xs:sequence> </xs:complextype> <xs:complextype name="custtype"> <xs:all> <xs:element name="zip" type="ziptype"/> <xs:element name="first" type="nametype"/> <xs:element ref="mi"/> <xs:element name="last" type="nametype"/> </xs:all> </xs:complextype>... Try It: Validate purchase.xml against purchase.xsd. Replace the mi element in purchase.xml with an empty nomiddleinit element. Validate the document again ITCourseware, LLC Rev Page 17

16 All and Choice Elements The all element is identical to the sequence element except the contents inside the group may appear in any order. The minoccurs and maxoccurs attributes of elements within an all element cannot have a value greater than one. You cannot nest the all element inside a sequence or choice element. Use the choice element to create a list of options from which one element will appear in the target document. <xs:complextype name="paymenttype"> <xs:choice> <xs:element name="cash" type="xs:decimal" /> <xs:element name="creditcard" type="xs:decimal" /> <xs:element name="check" type="xs:decimal" /> </xs:choice> </xs:complextype> Place the choice element inside complextype, sequence, group, choice, restriction, or extension elements. The choice element can contain annotation, any, choice, element, group, or sequence child elements. Page 18 Rev ITCourseware, LLC

17 Chapter 2 Defining New Types Using Schemas purchase.xsd <xs:schema xmlns:xs=" <xs:complextype name="purchasetype"> <xs:sequence> <xs:element name="customer" type="custtype"/> <xs:element name="total" type="totaltype"/> <xs:element name="guarantee" type="yesnotype"/> <xs:element name="deliver" type="yesnotype"/> <xs:element name="discountcodes" type="discountlisttype" /> <xs:element name="payment" type="paymenttype" /> </xs:sequence> </xs:complextype> The elements inside customer can appear in <xs:complextype name="custtype"> any order. <xs:all> <xs:element name="zip" type="ziptype"/> <xs:element name="first" type="nametype"/> <xs:element ref="mi"/> <xs:element name="last" type="nametype"/> </xs:all> </xs:complextype> Sorry, we don't take... checks. <xs:complextype name="paymenttype"> <xs:choice> <xs:element name="cash" type="newcashtype" /> <xs:element name="visacard" type="visamccardtype" /> <xs:element name="mccard" type="visamccardtype" /> <xs:element name="dinersclub" type="dinerscardtype" /> </xs:choice> </xs:complextype> ITCourseware, LLC Rev Page 19

18 Simple Type Restrictions The simpletype element allows new simple types to be declared and various restrictions, known as facets, to be applied to those types. The restriction element is a child of simpletype and contains the facet elements. Provide a mechanism to create upper and lower bounds for simple type values with the mininclusive, maxinclusive, minexclusive, and maxexclusive facets. Specify the boundary limit for the simple type with the value attribute. <xs:simpletype name="monthtype" <xs:restriction type="xs:integer"> <xs:mininclusive value="1" /> <xs:maxinclusive value="12" /> </xs:restriction> </xs:simpletype> You cannot use mininclusive and minexclusive inside the same restriction. The same is true of maxinclusive and maxexclusive. Define element lengths with the maxlength, minlength, and length facets. Use the facets' value attribute to define the length limit of the type. <xs:simpletype name="stateabbreviationtype" <xs:restriction type="xs:string"> <xs:length value="2" /> </xs:restriction> </xs:simpletype> You cannot use the maxlength and minlength facets in conjunction with the length facet. The value attribute for the minlength element must be less than the maxlength's value attribute. Page 20 Rev ITCourseware, LLC

19 Chapter 2 Defining New Types Using Schemas purchase.xsd <xs:schema xmlns:xs=" <xs:element name="purchase" type="purchasetype" /> <xs:element name="mi" type="mitype"/> <xs:element name="nomiddleinit" substitutiongroup="mi" type="nomitype" /> <xs:complextype name="purchasetype"> <xs:sequence> <xs:element name="customer" type="custtype"/> <xs:element name="total" type="totaltype"/> <xs:element name="guarantee" type="yesnotype"/> <xs:element name="deliver" type="yesnotype"/> <xs:element name="discountcodes" type="discountlisttype" /> <xs:element name="payment" type="paymenttype" /> </xs:sequence> </xs:complextype>... <xs:simpletype name="totaltype" > <xs:restriction base="xs:decimal"> <xs:mininclusive value="100.00" /> <xs:maxexclusive value=" " /> </xs:restriction> </xs:simpletype> <xs:simpletype name="nametype" > <xs:restriction base="xs:string"> <xs:minlength value="1" /> <xs:maxlength value="25" /> </xs:restriction> </xs:simpletype> <xs:simpletype name="mitype" > <xs:restriction base="xs:string"> <xs:minlength value="0" /> <xs:maxlength value="1" /> </xs:restriction> </xs:simpletype>... </xs:schema> Try It: Modify the middle initial element in purchase.xml so that it contains two characters. Validate the document to see an error generated ITCourseware, LLC Rev Page 21

20 Pattern and Enumeration Facets Use the pattern element inside the restriction element to match against regular expressions. <xs:simpletype name="uszipcodetype" <xs:restriction type="xs:string"> <xs:pattern value="^\d{5}$ ^\d{5}-\d{4}$" /> </xs:restriction> </xs:simpletype> Use the enumeration element to define a list of values that an element or attribute can contain. To create the list, add an enumeration element inside the restriction element for each potential value. <xs:simpletype name="creditcardtype" <xs:restriction type="xs:string"> <xs:enumeration value="american Express" /> <xs:enumeration value="master Card" /> <xs:enumeration value="visa" /> </xs:restriction> </xs:simpletype> Page 22 Rev ITCourseware, LLC

21 Chapter 2 Defining New Types Using Schemas purchase.xsd <xs:schema xmlns:xs=" <xs:element name="purchase" type="purchasetype" /> <xs:element name="mi" type="mitype"/> <xs:element name="nomiddleinit" substitutiongroup="mi" type="nomitype" /> <xs:complextype name="purchasetype"> <xs:sequence> <xs:element name="customer" type="custtype"/> <xs:element name="total" type="totaltype"/> <xs:element name="guarantee" type="yesnotype"/> <xs:element name="deliver" type="yesnotype"/> <xs:element name="discountcodes" type="discountlisttype" /> <xs:element name="payment" type="paymenttype" /> </xs:sequence> </xs:complextype>... <xs:simpletype name="yesnotype" > <xs:restriction base="xs:string"> <xs:enumeration value="yes" /> <xs:enumeration value="no" /> </xs:restriction> </xs:simpletype> Allows 5-digit and 9-digit zip codes. <xs:simpletype name="ziptype" > <xs:restriction base="xs:string"> <xs:pattern value="\d{5} \d{5}-\d{4}" /> </xs:restriction> </xs:simpletype>... </xs:schema> Try It: Modify the zip field in purchase.xml so that it contains six digits instead of five, and validate the document ITCourseware, LLC Rev Page 23

22 Union and List Use the union element to declare a new type as being a combination of other simpletypes. The membertypes attribute contains a whitespace-delimited list of simple types comprising the new type. <xs:simpletype name="numbertype"> <xs:union membertypes="xs:short xs:int xs:long" /> </xs:simpletype> If the union element does not contain a membertypes attribute, then it must contain anonymous simpletype child elements comprising the list of valid types. Use the list element to declare a type that contains a list of elements. The itemtype attribute contains the simple type that can be used in the value list. <xs:simpletype name="scorelisttype"> <xs:list itemtype="xs:integer" /> </xs:simpletype> Like the union element, the list element can contain a simpletype child element to declare the list type. The values in the element or attribute containing the list will be whitespacedelimited. <scores> </scores> Page 24 Rev ITCourseware, LLC

23 Chapter 2 Defining New Types Using Schemas purchase.xsd <xs:schema xmlns:xs=" <xs:element name="purchase" type="purchasetype" />... <xs:complextype name="purchasetype"> <xs:sequence> <xs:element name="customer" type="custtype"/> <xs:element name="total" type="totaltype"/> <xs:element name="guarantee" type="yesnotype"/> <xs:element name="deliver" type="yesnotype"/> <xs:element name="discountcodes" type="discountlisttype" /> <xs:element name="payment" type="paymenttype" /> </xs:sequence> </xs:complextype>... Purchases can have more <xs:simpletype name="discountlisttype" > than one discount. <xs:list itemtype="discountcodetype" /> </xs:simpletype> <xs:simpletype name="discountcodetype" > <xs:union> <xs:simpletype> <xs:restriction base="xs:string"> <xs:length value="3"/> </xs:restriction> </xs:simpletype> <xs:simpletype> <xs:restriction base="xs:integer"> <xs:maxexclusive value="10" /> <xs:minexclusive value="0" /> </xs:restriction> </xs:simpletype> </xs:union> </xs:simpletype>... Discount codes can be three-character strings or the numbers 1 through 9. Try It: Add a three-digit discount code to the discountcode element in purchase.xml. Does it validate? Why or why not? 2013 ITCourseware, LLC Rev Page 25

24 Complex Types and Extensions You can use the extension element inside a complextype to derive from an existing base type and add to it. The base attribute on the extension element declares which base type is being extended. If the value of the base attribute is a simple type, then the extension element can only contain attributes and is contained in a simplecontent element. <xs:complextype name="parttype"> <xs:simplecontent> <xs:extension base="xs:string"> <xs:attribute name="instock" type="xs:string" /> <xs:attribute name="reorder" type="xs:string" /> </xs:extension> </xs:simplecontent> </xs:complextype> If the value of the base attribute is a complex type, then the extension is contained in a complexcontent element and can contain additional elements as well as attributes. <xs:complextype name="employeetype"> <xs:complexcontent> <xs:extension base="persontype"> <xs:sequence> <xs:element name="socsecno" type="ssntype" /> </xs:sequence> </xs:extension> </xs:complexcontent> </xs:complextype> When you insert elements inside the extension, the new elements logically follow the elements in the base type. Page 26 Rev ITCourseware, LLC

25 Chapter 2 Defining New Types Using Schemas purchase.xsd <xs:schema xmlns:xs=" Add an attribute to an <xs:complextype name="cashtype"> element containing a <xs:simplecontent> decimal. <xs:extension base="xs:decimal"> <xs:attribute name="currency" type="xs:string" /> </xs:extension> </xs:simplecontent> </xs:complextype>... <xs:complextype name="creditcardtype"> <xs:sequence> <xs:element name="cardnumber" type="xs:string" /> <xs:element name="expdate" type="xs:date" /> </xs:sequence> </xs:complextype>... <xs:complextype name="visamccardtype" final="#all"> <xs:complexcontent> <xs:extension base="creditcardtype"> <xs:sequence> <xs:element name="cvv" type="xs:string" /> </xs:sequence> </xs:extension> </xs:complexcontent> Add a cvv element after </xs:complextype> the expdate. </xs:schema> 2013 ITCourseware, LLC Rev Page 27

26 Complex Types and Restrictions Use the restriction element to derive from a base complex type and add more restrictions to that type. Any facets added to attributes of the derived type must have a tighter degree of value or occurrence than the declaration in the base type. <xs:complextype name="inhouseparttype"> <xs:simplecontent> <xs:restriction base="parttype"> <xs:attribute name="reorder" use="prohibited" /> </xs:restriction> </xs:simplecontent> </xs:complextype> The derived type may not remove any required attributes declared in the base type. If the base type does not contain child elements, then the restriction should contain facets that put a higher degree of restriction on the elements' attributes or content. If the base type contains child elements, then the restriction must list all the mandatory elements of the base type and the base types ancestors. Any additional facets on the child elements must be more restrictive than the declaration in the base type. The new derived type must be a valid instance of the base type, just more restrictive. Page 28 Rev ITCourseware, LLC

27 Chapter 2 Defining New Types Using Schemas purchase.xsd... No restriction on <xs:complextype name="creditcardtype"> cardnumber. <xs:sequence> <xs:element name="cardnumber" type="xs:string" /> <xs:element name="expdate" type="xs:date" /> </xs:sequence> </xs:complextype> <xs:complextype name="dinerscardtype" final="#all"> <xs:complexcontent> <xs:restriction base="creditcardtype"> <xs:sequence> <xs:element name="cardnumber"> <xs:simpletype> <xs:restriction base="xs:string"> <xs:length value="14" /> The card number must </xs:restriction> now be 14 characters. </xs:simpletype> </xs:element> <xs:element name="expdate" type="xs:date" /> </xs:sequence> </xs:restriction> You still need to define the expdate element even </xs:complexcontent> though it is no different from </xs:complextype> the base type ITCourseware, LLC Rev Page 29

28 The final Attribute Use the final attribute of simple and complex type declarations to restrict how that type can be used with respect to other type declarations The final attribute contains a token list of values to indicate how the base type can be derived. For a complex type, use the final attribute to disallow it from being extended or restricted. The restriction token means that any restriction element within the schema may not use this complex type for its base type. The extension token means that any extension element within the schema may not use this complex type for its base type. The #all token means that both extension or restriction elements within the schema may not use this complex type for its base type. The tokens for the final attribute on a simple type vary from its complex type counterpart. The restriction token means the same as it does for the complex type. The list token means that simple types derived by list cannot use this type as a member of the type list. The union token means that simple types derived by union cannot use this type as a member of the union list. The #all token indicates that all of the three previous tokens apply to this simple type. Page 30 Rev ITCourseware, LLC

29 Chapter 2 Defining New Types Using Schemas purchase.xsd <xs:schema xmlns:xs=" <xs:simpletype name="currencytype" final="#all"> <xs:restriction base="xs:string"> <xs:enumeration value="us" /> <xs:enumeration value="uk" /> </xs:restriction> </xs:simpletype>... <xs:complextype name="dinerscardtype" final="#all"> <xs:complexcontent> <xs:restriction base="creditcardtype"> <xs:sequence> <xs:element name="cardnumber"> <xs:simpletype> <xs:restriction base="xs:string"> <xs:length value="14" /> </xs:restriction> </xs:simpletype> </xs:element> <xs:element name="expdate" type="xs:date" /> </xs:sequence> </xs:restriction> </xs:complexcontent> </xs:complextype> <xs:complextype name="visamccardtype" final="#all"> <xs:complexcontent> <xs:extension base="creditcardtype"> <xs:sequence> <xs:element name="cvv" type="xs:string" /> </xs:sequence> </xs:extension> </xs:complexcontent> </xs:complextype> </xs:schema> Investigate: Try to extend the visamctype in a new complextype. What happens when you try to validate purchase.xml? 2013 ITCourseware, LLC Rev Page 31

30 Labs Create a schema called student.xsd to validate the XML file on the facing page. The schema should have the following characteristics: a) The middle initial should not allow more than one character. b) The gpa element should not be greater than 4.0 and not less than 0. c) The emergencycontact element should be the same as the name element but with an extension of the relationship element. d) The areacode element should have three digits. e) The number element should have the following pattern " " f) The unitscompleted element should be an integer and not negative. g) The class field should only allow Freshman, Sophomore, Junior, or Senior values. h) The last element inside of the student element can either be an ssn element or a visanumber element. i) The coursenumbers element should only allow integers in the list. (Solution: student.xsd) Validate student.xml against your new schema. Page 32 Rev ITCourseware, LLC

31 Chapter 2 Defining New Types Using Schemas student.xml <student xmlns:xsi=" xsi:nonamespaceschemalocation="student.xsd"> <name> <first>philip</first> <last>seitz</last> <mi>j</mi> </name> <emergencycontact> <first>coralee</first> <last>seitz</last> <mi>s</mi> <relationship>mother</relationship> </emergencycontact> <phone> <areacode>303</areacode> <number> </number> </phone> <gpa>4.0</gpa> <class>freshman</class> <unitscompleted>30</unitscompleted> <ssn> </ssn> <coursenumbers> </courseNumbers> </student> 2013 ITCourseware, LLC Rev Page 33

32 Chapter 7 Advanced XSLT Chapter 7 - Advanced XSLT Objectives Create and format numbers in the result document. Create and assign values to variables within a stylesheet. Pass parameters to templates within an XSLT stylesheet. Import templates from other XSLT stylesheets. Define precedence of XSLT templates ITCourseware, LLC Rev Page 115

33 Copying Elements It may be necessary to copy elements from the source document to the target document. XSLT provides two different methods for copying content. The xsl:copy element copies the current node to the output document. If the current node is an element, it does not copy attributes or element content. It always implicitly copies the context node. It may use attribute sets. The xsl:copy-of element is similar to the xsl:value-of element. It accepts a target argument using the select attribute. It copies an entire result-tree fragment. Copying an element also copies attributes, attribute values, and element content. Page 116 Rev ITCourseware, LLC

34 Chapter 7 Advanced XSLT Particularly for XML-to-XML applications, the ability to copy portions of the source document directly into the output document is useful. The following XSLT template copies all of the content from the source document to the target document: copydoc.xsl <xsl:stylesheet version="2.0" xmlns:xsl=" <xsl:template match="@* node()"> <xsl:copy> <xsl:apply-templates select="@* node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> Try It: Copy the contents from the source document, apollo.xml, to the result document by transforming apollo.xml with copydoc.xsl ITCourseware, LLC Rev Page 117

35 Numbering The xsl:number element supports generating rich numbering sequences in output documents. The value attribute is an XPath expression that returns the number to be printed Instead of using the value attribute, the number can be calculated based upon the position of the node. The count, from, and level attributes are used when value is omitted. The count attribute is an XPath expression indicating what is to be counted. The from attribute is an XPath expression that indicates the element where counting begins. The level attribute controls how elements are counted. The level attribute influences how the other attributes are applied. A level of single is the default, and numbers adjacent elements in a simple list. A level of multiple creates a hierarchical numbering scheme (i.e., outline numbering). A level of any counts any preceding matching element (for instance, for numbering figures or diagrams). The final output format can be modified by the format attribute. Numerous types of numbering are defined (Arabic, Roman numerals, lettering, etc.). Page 118 Rev ITCourseware, LLC

36 Chapter 7 Advanced XSLT Use the following values for the format attribute: Format Result "1" "01" "a" a b c... "A" A B C... "I" i ii iii iv... "I" I II III IV... orbits1.xsl <xsl:stylesheet version="2.0" xmlns:xsl=" <xsl:output method="html"/> <xsl:template match="apollo"> <html> <body> <h1>apollo Table</h1> <table border="1"> <tr> <th>mission Number</th><th>Orbit Count</th> </tr> <xsl:apply-templates select="mission[lunar/orbit/count]"/> </table> </body> </html> </xsl:template> <xsl:template match="mission"> <tr> <td><xsl:value-of select="./text()" /></td> <td><xsl:number value=".//orbit/count" format="1"/></td> <!--<td><xsl:number value=".//orbit/count" format="i"/></td>--> </tr> </xsl:template> </xsl:stylesheet> Try It: Run orbits1.xsl against the source document, apollo.xml. Notice how the orbit numbers are presented depending on the parameter values ITCourseware, LLC Rev Page 119

37 Variables You can use variables to hold values that you need to use somewhere else in your stylesheet. If you have a variable named var, access it within XSLT elements with the $var notation. To define a variable, use the xsl:variable element. This element can be a top-level element or a child of any other element. The parent element of xsl:variable defines the scope of the variable. xsl:variable can have two attributes. The name attribute defines the name of the variable. The select attribute defines the value of the variable. Use single quotes around a literal value to prevent the processor from evaluating it. Most processors will recognize a literal value that starts with a number, even if it is not surrounded by single quotes. If you don't specify the select attribute of the xsl:variable, its value will be an empty string. You can reassign values to variables with another xsl:variable element. When you reassign values, be careful of the variable's scope. Page 120 Rev ITCourseware, LLC

38 Chapter 7 Advanced XSLT orbits2.xsl <xsl:stylesheet version="2.0" xmlns:xsl=" <xsl:output method="html"/> <xsl:variable name="orbit_limit" select="20" /> <xsl:template match="apollo"> <html> <body> <h1>apollo Table</h1> <table border="1"> <tr> <th>mission Number</th><th>Orbit Count</th> </tr> <xsl:apply-templates select="mission[.//orbit/count > $orbit_limit]"/> </table> </body> </html> Obtains value of </xsl:template> orbit_limit variable. <xsl:template match="mission"> <tr> <td><xsl:value-of select="./text()" /></td> <td><xsl:number value=".//orbit/count" format="1"/></td> </tr> </xsl:template> </xsl:stylesheet> Try It: Run orbits2.xsl against the source document, apollo.xml. Are there any apollo missions missing from the output? Add an additional variable named orbit_limit inside the template that matches apollo and give it the select value of 5. Perform the transformation again and look for any change in the output. Which orbit_limit variable has priority? 2013 ITCourseware, LLC Rev Page 121

39 Parameters You can pass parameters to a stylesheet or a template to provide additional information. Use the xsl:param element to define the parameters that the stylesheet or template can accept. If the xsl:param element is a top-level element, the parameter is global. The parameter value can be passed in on the command line. If the xsl:param element is a child of a template, the parameter is local to that template. Define the name of the parameter with the name attribute. You can specify a default value with the select attribute or defined as a template within the xsl:param element. Enclose literal values within single quotes if you use the select attribute. Set the parameter value with an xsl:with-param element as a child of the template call. The xsl:with-param has the same attributes as the xsl:param element. Access the value of the parameter using $param notation, just like a variable. Page 122 Rev ITCourseware, LLC

40 Chapter 7 Advanced XSLT To pass a parameter to a template, include the xsl:with-param element as a child of the element that invokes the template: <xsl:call-template name="header"> <xsl:with-param name="background" select="preferences/background"/> </xsl:call-template> or <xsl:apply-templates select="descendant::astronaut"> <xsl:with-param name="title" select="'astronaut'"/> </xsl:apply-templates> Consult your processor's documentation for details on passing a parameter to a stylesheet. orbits3.xsl <xsl:stylesheet version="2.0" xmlns:xsl=" <xsl:output method="html"/> <xsl:variable name="orbit_limit" select="20" />... <xsl:apply-templates select="mission[.//orbit/count > $orbit_limit]"> <xsl:with-param name="numberformat" select="'1'" /> </xsl:apply-templates> </table> </body> The parameter </html> value is "1." </xsl:template> <xsl:template match="mission"> <xsl:param name="numberformat">i</xsl:param> <tr> The default value is "I." <td><xsl:value-of select="./text()" /></td> <td> <xsl:number value=".//orbit/count" format="{$numberformat}"/> </td> </tr> </xsl:template> </xsl:stylesheet> Try It: Run orbits3.xsl against the source document, apollo.xml. Modify orbits3.xsl by removing the xsl:withparam element and run it again. What changed in the output? 2013 ITCourseware, LLC Rev Page 123

41 Using Other Stylesheets XSLT provides two elements for using templates from other stylesheets: xsl:import and xsl:include. The stylesheet that contains the xsl:import or xsl:include element is the including stylesheet. The stylesheet that is being imported or included is the included stylesheet. The xsl:import and xsl:include elements allow you to include templates from another stylesheet into the including stylesheet. Both are empty elements. The href attribute specifies the URI of the included stylesheet. xsl:import can only appear at the beginning of the including stylesheet. All imported templates have a lower priority than the templates in the including stylesheet. xsl:include can be anywhere in the stylesheet, as long as it is a top-level element. The included templates have the same priority as the templates from the including stylesheet. Page 124 Rev ITCourseware, LLC

42 Chapter 7 Advanced XSLT external.xsl <xsl:stylesheet version="2.0" xmlns:xsl=" <xsl:template match="mission"> <tr bgcolor="cyan"> <td><xsl:value-of select="./text()" /></td> <td> <xsl:number value=".//orbit/count" format="a"/> </td> </tr> </xsl:template> </xsl:stylesheet> orbits4.xsl <xsl:stylesheet version="2.0" xmlns:xsl=" <xsl:import href="external.xsl"/> external.xsl contains the <xsl:output method="html"/> same mission template as... orbits4.xsl. <xsl:template match="mission"> <xsl:param name="numberformat">i</xsl:param> <tr> <td><xsl:value-of select="./text()" /></td> <td> <xsl:number value=".//orbit/count" format="{$numberformat}"/> </td> </tr> </xsl:template> </xsl:stylesheet> Try It: Run orbits4.xsl against the source document, apollo.xml. Is the output different? Change the xsl:import to an xsl:include. Is the output different? Move the xsl:include to the bottom of the stylesheet. Is the output different? 2013 ITCourseware, LLC Rev Page 125

43 Apply-imports When you import another stylesheet using xsl:import, the templates in the other stylesheet have a lower priority than those in the primary stylesheet. You can call the template in the imported stylesheet from a template with the same matching XPath in the primary stylesheet using the xsl:apply-imports element. The basic effect is the same as calling a template by name. If the imported template takes parameters, you can provide xsl:withparam elements inside the xsl:apply-imports element. Page 126 Rev ITCourseware, LLC

44 Chapter 7 Advanced XSLT orbits5.xsl <xsl:stylesheet version="2.0" xmlns:xsl=" <xsl:import href="external.xsl"/> <xsl:output method="html"/> <xsl:variable name="orbit_limit" select="20" /> <xsl:template match="apollo"> <html> <body> <h1>apollo Table</h1> <table border="1"> <tr> <th>mission Number</th><th>Orbit Count</th> </tr> <xsl:apply-templates select="mission[.//orbit/count > $orbit_limit]"> <xsl:with-param name="numberformat" select="'1'" /> </xsl:apply-templates> </table> </body> </html> </xsl:template> <xsl:template match="mission"> <xsl:param name="numberformat">i</xsl:param> <tr> <td><xsl:value-of select="./text()" /></td> <td> <xsl:number value=".//orbit/count" format="{$numberformat}"/> </td> </tr> <xsl:apply-imports/> Calls the same template </xsl:template> in external.xsl. </xsl:stylesheet> Try It: Transform apollo.xml with orbits5.xsl. What changed? 2013 ITCourseware, LLC Rev Page 127

45 Template Rule Conflicts It is possible that you will have multiple templates that will match a given source node. Only one template will be applied as the node is processed. Conflicts between templates are resolved by the priority of the template. Imported templates have a lower priority than templates in the including stylesheet. You can specify a priority with the priority attribute of the xsl:template element, using any number other than infinity. The template with the higher priority number wins. Otherwise, a default priority is calculated by the processor. Page 128 Rev ITCourseware, LLC

46 Chapter 7 Advanced XSLT The formula used by XSLT processors to select matching templates is somewhat involved. The basic steps are: 1. Find every template that could possibly match the current source document context node. 2. Rank them by import precedence and discard all but the highest precedence templates (i.e., don't consider imported templates if built-in templates are available). 3. For each remaining template, determine its priority: If the xsl:template element has an explicit priority attribute, use it. Otherwise, calculate the priority using the following rules (from the XSLT recommendation): a. If the pattern contains multiple alternatives separated by, then it is treated equivalently to a set of template rules, one for each alternative. b. Any templates that match on an element name or attribute name have a priority of 0. c. Matches with the processing-instruction() function also have a priority of 0. d. Any matches that use prefix:* have a priority of e. Any templates that match with comment(), node(), text(), * have a priority of f. Everything else has the priority of If more than one template has the same priority value, the processor can either return an error to the user or choose the template that was declared last in the document ITCourseware, LLC Rev Page 129

47 Extensions The XSLT specification allows you to add additional capabilities to your stylesheets through extensions. Most XSLT processors define their own extensions. Most also provide a mechanism for you to create your own. Two types of extensions are defined: extension elements and extension functions. Extensions are written in a programming language and are external to the XSLT processor. The external programs have access to the source tree and can generate output for the result tree. The xsl:stylesheet element should specify the namespace of the extension. For extension elements, include an extension-element-prefixes attribute. <xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:ext="com.example.extensions" extension-element-prefixes="ext"> You can use the element-available() function to test whether a given element is available ahead of time. Use this as the test value of an xsl:if or xsl:when element. There is also a function-available() function. The xsl:fallback element works kind of like an exception handler. It defines a template that will be used if an extension element or function doesn't exist. It must be used inside an xsl:template element and has no attributes. Page 130 Rev ITCourseware, LLC

48 Chapter 7 Advanced XSLT extensions.xsl <xsl:stylesheet version="2.0" xmlns:xsl=" xmlns:ext="com.example.extensions" extension-element-prefixes="ext"> <xsl:template match="/"> <ext:dosomethingcool> <xsl:fallback> <xsl:message> The extensions library is unavailable. </xsl:message> </xsl:fallback> </ext:dosomethingcool> </xsl:template> </xsl:stylesheet> The xsl:message element is used to send output to somewhere other than the result tree. Most processors will send the contents of the xsl:message element to stdout. The optional terminate attribute can be set to yes or no to indicate whether to halt execution upon encountering the message. Try It: If your processor supports output messages, transform apollo.xml with extensions.xsl to see fallback processing occur ITCourseware, LLC Rev Page 131

49 Labs Create an XSLT stylesheet that reads cart.xml and outputs an HTML table with all the items that are less than $30. The table should contain three columns: a line number, the product name, and the line total. Store the $30 limit in a variable called topprice at the top level of the stylesheet. (Solution: purchase1.xsl) Modify the stylesheet so the line numbers are presented as Roman numerals. (Solution: purchase2.xsl) Create a new stylesheet that contains a template named header that provides a nice header for your HTML output. Import the stylesheet into your original stylesheet. Call the header so it is displayed above your table. (Solutions: purchase3.xsl, external1.xsl) Modify the imported stylesheet and add a template that will provide the total line in the table of all the purchased items. Pass the value of the topprice variable to the template as a parameter. Modify the the original stylesheet so it adds the total line at the bottom of the HTML table. (Solutions: purchase4.xsl, external2.xsl) Modify your solution again to display the total with two decimal places. (Solutions: purchase5.xsl, external3.xsl) Page 132 Rev ITCourseware, LLC

Advanced XML. Student Workbook

Advanced XML. Student Workbook Student Workbook Advanced XML Robert Seitz Published by ITCourseware, LLC. 7245 South Havana Street, Suite 100, Englewood, CO 80112 Technical Editor: Jamie Romero Copyeditor: Danielle North Special thanks

More information

Appendix H XML Quick Reference

Appendix H XML Quick Reference HTML Appendix H XML Quick Reference What Is XML? Extensible Markup Language (XML) is a subset of the Standard Generalized Markup Language (SGML). XML allows developers to create their own document elements

More information

XML Schema. Mario Alviano A.Y. 2017/2018. University of Calabria, Italy 1 / 28

XML Schema. Mario Alviano A.Y. 2017/2018. University of Calabria, Italy 1 / 28 1 / 28 XML Schema Mario Alviano University of Calabria, Italy A.Y. 2017/2018 Outline 2 / 28 1 Introduction 2 Elements 3 Simple and complex types 4 Attributes 5 Groups and built-in 6 Import of other schemes

More information

Markup Languages. Lecture 4. XML Schema

Markup Languages. Lecture 4. XML Schema Markup Languages Lecture 4. XML Schema Introduction to XML Schema XML Schema is an XML-based alternative to DTD. An XML schema describes the structure of an XML document. The XML Schema language is also

More information

XSL Elements. xsl:copy-of

XSL Elements. xsl:copy-of XSL Elements The following elements are discussed on this page: xsl:copy-of xsl:value-of xsl:variable xsl:param xsl:if xsl:when xsl:otherwise xsl:comment xsl:import xsl:output xsl:template xsl:call-template

More information

Semantic Web. XML and XML Schema. Morteza Amini. Sharif University of Technology Fall 94-95

Semantic Web. XML and XML Schema. Morteza Amini. Sharif University of Technology Fall 94-95 ه عا ی Semantic Web XML and XML Schema Morteza Amini Sharif University of Technology Fall 94-95 Outline Markup Languages XML Building Blocks XML Applications Namespaces XML Schema 2 Outline Markup Languages

More information

Restricting complextypes that have mixed content

Restricting complextypes that have mixed content Restricting complextypes that have mixed content Roger L. Costello October 2012 complextype with mixed content (no attributes) Here is a complextype with mixed content:

More information

XSLT: How Do We Use It?

XSLT: How Do We Use It? XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman 1 XSLT: Agenda Introduction & Terminology XSLT Walkthrough Client-Side XSLT/XHTML Server-Side XSLT/XHTML More Creative Server-Side XSLT 2 XSLT:

More information

XML Schema Element and Attribute Reference

XML Schema Element and Attribute Reference E XML Schema Element and Attribute Reference all This appendix provides a full listing of all elements within the XML Schema Structures Recommendation (found at http://www.w3.org/tr/xmlschema-1/). The

More information

So far, we've discussed the use of XML in creating web services. How does this work? What other things can we do with it?

So far, we've discussed the use of XML in creating web services. How does this work? What other things can we do with it? XML Page 1 XML and web services Monday, March 14, 2011 2:50 PM So far, we've discussed the use of XML in creating web services. How does this work? What other things can we do with it? XML Page 2 Where

More information

Introducing our First Schema

Introducing our First Schema 1 di 11 21/05/2006 10.24 Published on XML.com http://www.xml.com/pub/a/2000/11/29/schemas/part1.html See this if you're having trouble printing code examples Using W3C XML By Eric van der Vlist October

More information

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Advanced Computer Science. Date: Tuesday 20 th May 2008.

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Advanced Computer Science. Date: Tuesday 20 th May 2008. COMP60370 Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE M.Sc. in Advanced Computer Science Semi-Structured Data and the Web Date: Tuesday 20 th May 2008 Time: 09:45 11:45 Please answer

More information

PESC Compliant JSON Version /19/2018. A publication of the Technical Advisory Board Postsecondary Electronic Standards Council

PESC Compliant JSON Version /19/2018. A publication of the Technical Advisory Board Postsecondary Electronic Standards Council Version 0.5.0 10/19/2018 A publication of the Technical Advisory Board Postsecondary Electronic Standards Council 2018. All Rights Reserved. This document may be copied and furnished to others, and derivative

More information

XPath and XSLT. Overview. Context. Context The Basics of XPath. XPath and XSLT. Nodes Axes Expressions. Stylesheet templates Transformations

XPath and XSLT. Overview. Context. Context The Basics of XPath. XPath and XSLT. Nodes Axes Expressions. Stylesheet templates Transformations XPath and XSLT Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring Context The Basics of XPath Nodes

More information

Computer Science E-259

Computer Science E-259 Computer Science E-259 XML with Java Lecture 5: XPath 1.0 (and 2.0) and XSLT 1.0 (and 2.0), Continued 22 October 2007 David J. Malan malan@post.harvard.edu 1 Computer Science E-259 Last Time CSS Level

More information

Syntax XML Schema XML Techniques for E-Commerce, Budapest 2004

Syntax XML Schema XML Techniques for E-Commerce, Budapest 2004 Mag. iur. Dr. techn. Michael Sonntag Syntax XML Schema XML Techniques for E-Commerce, Budapest 2004 E-Mail: sonntag@fim.uni-linz.ac.at http://www.fim.uni-linz.ac.at/staff/sonntag.htm Michael Sonntag 2004

More information

Author: Irena Holubová Lecturer: Martin Svoboda

Author: Irena Holubová Lecturer: Martin Svoboda NPRG036 XML Technologies Lecture 6 XSLT 9. 4. 2018 Author: Irena Holubová Lecturer: Martin Svoboda http://www.ksi.mff.cuni.cz/~svoboda/courses/172-nprg036/ Lecture Outline XSLT Principles Templates Instructions

More information

XML Wrap-up. CS 431 March 1, 2006 Carl Lagoze Cornell University

XML Wrap-up. CS 431 March 1, 2006 Carl Lagoze Cornell University XML Wrap-up CS 431 March 1, 2006 Carl Lagoze Cornell University XSLT Processing Model Input XSL doc parse Input XML doc parse Parsed tree serialize Input XML doc Parsed tree Xformed tree Output doc (xml,

More information

Exam : Title : XML 1.1 and Related Technologies. Version : DEMO

Exam : Title : XML 1.1 and Related Technologies. Version : DEMO Exam : 000-142 Title : XML 1.1 and Related Technologies Version : DEMO 1. XML data is stored and retrieved within a relational database for a data-centric application by means of mapping XML schema elements

More information

Schema schema-for-json.xsd

Schema schema-for-json.xsd Schema schema-for-json.xsd schema location: attributeformdefault: elementformdefault: targetnamespace:..\schema-for-json.xsd qualified http://www.w3.org/2015/exi/json Elements Complex types Simple types

More information

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

Delivery Options: Attend face-to-face in the classroom or remote-live attendance. XML Programming Duration: 5 Days Price: $2795 *California residents and government employees call for pricing. Discounts: We offer multiple discount options. Click here for more info. Delivery Options:

More information

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance.

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance. XML Programming Duration: 5 Days US Price: $2795 UK Price: 1,995 *Prices are subject to VAT CA Price: CDN$3,275 *Prices are subject to GST/HST Delivery Options: Attend face-to-face in the classroom or

More information

Advanced XSLT. Web Data Management and Distribution. Serge Abiteboul Ioana Manolescu Philippe Rigaux Marie-Christine Rousset Pierre Senellart

Advanced XSLT. Web Data Management and Distribution. Serge Abiteboul Ioana Manolescu Philippe Rigaux Marie-Christine Rousset Pierre Senellart Advanced XSLT Web Data Management and Distribution Serge Abiteboul Ioana Manolescu Philippe Rigaux Marie-Christine Rousset Pierre Senellart Web Data Management and Distribution http://webdam.inria.fr/textbook

More information

XML extensible Markup Language

XML extensible Markup Language extensible Markup Language Eshcar Hillel Sources: http://www.w3schools.com http://java.sun.com/webservices/jaxp/ learning/tutorial/index.html Tutorial Outline What is? syntax rules Schema Document Object

More information

Software Engineering Methods, XML extensible Markup Language. Tutorial Outline. An Example File: Note.xml XML 1

Software Engineering Methods, XML extensible Markup Language. Tutorial Outline. An Example File: Note.xml XML 1 extensible Markup Language Eshcar Hillel Sources: http://www.w3schools.com http://java.sun.com/webservices/jaxp/ learning/tutorial/index.html Tutorial Outline What is? syntax rules Schema Document Object

More information

Introduction to XSLT

Introduction to XSLT Introduction to XSLT Justin Tilton, Chief Executive Officer instructional media + magic, inc. at the JA-SIG Conference Vancouver, BC Sunday, June 9, 2002 The Abstract Looking for a methodology to quickly

More information

PESC Compliant JSON Version /04/2019

PESC Compliant JSON Version /04/2019 Version 1.0.0 02/04/2019 A publication of the Technical Advisory Board, 2018. This document is released and all use of it is controlled under Creative Commons, specifically under an Attribution- ShareAlike

More information

Advanced XSLT. Web Data Management and Distribution. Serge Abiteboul Philippe Rigaux Marie-Christine Rousset Pierre Senellart

Advanced XSLT. Web Data Management and Distribution. Serge Abiteboul Philippe Rigaux Marie-Christine Rousset Pierre Senellart Advanced XSLT Web Data Management and Distribution Serge Abiteboul Philippe Rigaux Marie-Christine Rousset Pierre Senellart http://gemo.futurs.inria.fr/wdmd January 15, 2010 Gemo, Lamsade, LIG, Télécom

More information

Automatic Configurator for Application Code

Automatic Configurator for Application Code Automatic Configurator for Application Code ROXANA MUREŞAN 1, ANDREI BOTOACĂ 2, HORIA CIOCÂRLIE 1 1 Computer and Software Engineering Department Politehnica University of Timisoara V. Pârvan street 2,

More information

EXAM XML 1.1 and Related Technologies TYPE: DEMO

EXAM XML 1.1 and Related Technologies TYPE: DEMO IBM EXAM - 000-142 XML 1.1 and Related Technologies TYPE: DEMO http://www.examskey.com/000-142.html 1 Question: 1 XML data is stored and retrieved within a relational database for a data-centric application

More information

Extensible Markup Stylesheet Transformation (XSLT)

Extensible Markup Stylesheet Transformation (XSLT) Extensible Markup Stylesheet Transformation (XSLT) Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Dept. of Computer Engineering Khon Kaen University 1 Overview Terms: XSL, XSLT, XSL-FO Value

More information

XML. Objectives. Duration. Audience. Pre-Requisites

XML. Objectives. Duration. Audience. Pre-Requisites XML XML - extensible Markup Language is a family of standardized data formats. XML is used for data transmission and storage. Common applications of XML include business to business transactions, web services

More information

XSL Transformation (XSLT) XSLT Processors. Example XSLT Stylesheet. Calling XSLT Processor. XSLT Structure

XSL Transformation (XSLT) XSLT Processors. Example XSLT Stylesheet. Calling XSLT Processor. XSLT Structure Transformation (T) SOURCE The very best of Cat Stevens UK 8.90 1990 Empire Burlesque Bob

More information

XML Format Plug-in User s Guide. Version 10g Release 3 (10.3)

XML Format Plug-in User s Guide. Version 10g Release 3 (10.3) XML Format Plug-in User s Guide Version 10g Release 3 (10.3) XML... 4 TERMINOLOGY... 4 CREATING AN XML FORMAT... 5 CREATING AN XML FORMAT BASED ON AN EXISTING XML MESSAGE FORMAT... 5 CREATING AN EMPTY

More information

XSLT. Announcements (October 24) XSLT. CPS 116 Introduction to Database Systems. Homework #3 due next Tuesday Project milestone #2 due November 9

XSLT. Announcements (October 24) XSLT. CPS 116 Introduction to Database Systems. Homework #3 due next Tuesday Project milestone #2 due November 9 XSLT CPS 116 Introduction to Database Systems Announcements (October 24) 2 Homework #3 due next Tuesday Project milestone #2 due November 9 XSLT 3 XML-to-XML rule-based transformation language Used most

More information

Semi-structured Data 11 - XSLT

Semi-structured Data 11 - XSLT Semi-structured Data 11 - XSLT Andreas Pieris and Wolfgang Fischl, Summer Term 2016 Outline What is XSLT? XSLT at First Glance XSLT Templates Creating Output Further Features What is XSLT? XSL = extensible

More information

Lars Schmidt-Thieme, Information Systems and Machine Learning Lab (ISMLL), University of Hildesheim, Germany, Course on XML and Semantic Web

Lars Schmidt-Thieme, Information Systems and Machine Learning Lab (ISMLL), University of Hildesheim, Germany, Course on XML and Semantic Web Course on XML and Semantic Web Technologies, summer term 2012 0/44 XML and Semantic Web Technologies XML and Semantic Web Technologies I. XML / 5. XML Stylesheet Language Transformations (XSLT) Lars Schmidt-Thieme

More information

EVALUATION COPY. The Unified Modeling Language. Unauthorized reproduction or distribution is prohibited. Student Workbook

EVALUATION COPY. The Unified Modeling Language. Unauthorized reproduction or distribution is prohibited. Student Workbook The Unified Modeling Language Student Workbook The Unified Modeling Language The Unified Modeling Language Lynwood Wilson Published by ITCourseware, LLC., 7245 South Havana Street, Suite 100, Centennial,

More information

Modelling XML Applications (part 2)

Modelling XML Applications (part 2) Modelling XML Applications (part 2) Patryk Czarnik XML and Applications 2014/2015 Lecture 3 20.10.2014 Common design decisions Natural language Which natural language to use? It would be a nonsense not

More information

XML and Databases. Lecture 11 XSLT Stylesheets and Transforms. Sebastian Maneth NICTA and UNSW

XML and Databases. Lecture 11 XSLT Stylesheets and Transforms. Sebastian Maneth NICTA and UNSW XML and Databases Lecture 11 XSLT Stylesheets and Transforms Sebastian Maneth NICTA and UNSW CSE@UNSW -- Semester 1, 2010 Outline 1. extensible Stylesheet Language Transformations (XSLT) 2. Templates:

More information

Introduction to XSLT

Introduction to XSLT Introduction to XSLT Justin Tilton, Chief Executive Officer instructional media + magic, inc. at the JA-SIG Conference Destin, Florida December 2, 2001 The Abstract Looking for a methodology to quickly

More information

XML. Part II DTD (cont.) and XML Schema

XML. Part II DTD (cont.) and XML Schema XML Part II DTD (cont.) and XML Schema Attribute Declarations Declare a list of allowable attributes for each element These lists are called ATTLIST declarations Consists of 3 basic parts The ATTLIST keyword

More information

XML. XML Namespaces, XML Schema, XSLT

XML. XML Namespaces, XML Schema, XSLT XML XML Namespaces, XML Schema, XSLT Contents XML Namespaces... 2 Namespace Prefixes and Declaration... 3 Multiple Namespace Declarations... 4 Declaring Namespaces in the Root Element... 5 Default Namespaces...

More information

Java EE 7: Back-end Server Application Development 4-2

Java EE 7: Back-end Server Application Development 4-2 Java EE 7: Back-end Server Application Development 4-2 XML describes data objects called XML documents that: Are composed of markup language for structuring the document data Support custom tags for data

More information

BEAWebLogic. Integration. Transforming Data Using XQuery Mapper

BEAWebLogic. Integration. Transforming Data Using XQuery Mapper BEAWebLogic Integration Transforming Data Using XQuery Mapper Version: 10.2 Document Revised: March 2008 Contents Introduction Overview of XQuery Mapper.............................................. 1-1

More information

Burrows & Langford Appendix D page 1 Learning Programming Using VISUAL BASIC.NET

Burrows & Langford Appendix D page 1 Learning Programming Using VISUAL BASIC.NET Burrows & Langford Appendix D page 1 APPENDIX D XSLT XSLT is a programming language defined by the World Wide Web Consortium, W3C (http://www.w3.org/tr/xslt), that provides the mechanism to transform a

More information

More XML Schemas, XSLT, Intro to PHP. CS174 Chris Pollett Oct 15, 2007.

More XML Schemas, XSLT, Intro to PHP. CS174 Chris Pollett Oct 15, 2007. More XML Schemas, XSLT, Intro to PHP CS174 Chris Pollett Oct 15, 2007. Outline XML Schemas XSLT PHP Overview of data types There are two categories of data types in XML Schemas: simple types -- which are

More information

XML and Databases. Outline XML. XML, typical usage scenario XML. 1. extensible Stylesheet Language X M L. Sebastian Maneth NICTA and UNSW

XML and Databases. Outline XML. XML, typical usage scenario XML. 1. extensible Stylesheet Language X M L. Sebastian Maneth NICTA and UNSW Outline XML and Databases 1. extensible Stylesheet Language Transformations (XSLT) 2. Templates (match pattern action) Lecture 11 XSLT Stylesheets and Transforms Sebastian Maneth NICTA and UNSW 3. Default

More information

CSC503 Exam 2. Assume that the following functional dependencies beyond that of the primary key are valid:

CSC503 Exam 2. Assume that the following functional dependencies beyond that of the primary key are valid: CSC503 Exam 2 Name: Question 1 Assume that you have the following table: (OrderID, OrderDate, DeliveryDate, CustomerID, CustomerName, CustomerEmail, CustomerCity, CustomerState, CustomerZip, (ProductID,

More information

XSLT program. XSLT elements. XSLT example. An XSLT program is an XML document containing

XSLT program. XSLT elements. XSLT example. An XSLT program is an XML document containing XSLT CPS 216 Advanced Database Systems Announcements (March 24) 2 Homework #3 will be assigned next Tuesday Reading assignment due next Wednesday XML processing in Lore (VLDB 1999) and Niagara (VLDB 2003)

More information

XSL and OU Campus. OmniUpdate User Training Conference OmniUpdate, Inc Flynn Road, Suite 100 Camarillo, CA 93012

XSL and OU Campus. OmniUpdate User Training Conference OmniUpdate, Inc Flynn Road, Suite 100 Camarillo, CA 93012 XSL and OU Campus OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn Road, Suite 100 Camarillo, CA 93012 OmniUpdate, Inc. 1320 Flynn Road, Suite 100 Camarillo, CA 93012 800.362.2605 805.484.9428

More information

COPYRIGHTED MATERIAL. Contents. Part I: Introduction 1. Chapter 1: What Is XML? 3. Chapter 2: Well-Formed XML 23. Acknowledgments

COPYRIGHTED MATERIAL. Contents. Part I: Introduction 1. Chapter 1: What Is XML? 3. Chapter 2: Well-Formed XML 23. Acknowledgments Acknowledgments Introduction ix xxvii Part I: Introduction 1 Chapter 1: What Is XML? 3 Of Data, Files, and Text 3 Binary Files 4 Text Files 5 A Brief History of Markup 6 So What Is XML? 7 What Does XML

More information

Framing how values are extracted from the data stream. Includes properties for alignment, length, and delimiters.

Framing how values are extracted from the data stream. Includes properties for alignment, length, and delimiters. DFDL Introduction For Beginners Lesson 3: DFDL properties In lesson 2 we learned that in the DFDL language, XML Schema conveys the basic structure of the data format being modeled, and DFDL properties

More information

Framing how values are extracted from the data stream. Includes properties for alignment, length, and delimiters.

Framing how values are extracted from the data stream. Includes properties for alignment, length, and delimiters. DFDL Introduction For Beginners Lesson 3: DFDL properties Version Author Date Change 1 S Hanson 2011-01-24 Created 2 S Hanson 2011-03-30 Updated 3 S Hanson 2012-09-21 Corrections for errata 4 S Hanson

More information

XSLT is... XML XSLT XSL-FO XPath

XSLT is... XML XSLT XSL-FO XPath XSLT XSLT is... XML XSLT XSL-FO XPath Назначение XSLT XML XML Назначение XSLT XML HTML Сервер Браузер Назначение XSLT XML HTML Сервер Браузер Declaration

More information

XSLT (part I) Mario Alviano A.Y. 2017/2018. University of Calabria, Italy 1 / 22

XSLT (part I) Mario Alviano A.Y. 2017/2018. University of Calabria, Italy 1 / 22 1 / 22 XSLT (part I) Mario Alviano University of Calabria, Italy A.Y. 2017/2018 Outline 2 / 22 1 Introduction 2 Templates 3 Attributes 4 Copy of elements 5 Exercises 4 / 22 What is XSLT? XSLT is a (Turing

More information

The Transformation Language XSL

The Transformation Language XSL Chapter 8 The Transformation Language XSL 8.1 XSL: Extensible Stylesheet Language developed from CSS (Cascading Stylesheets) scripting language for transformation of data sources to HTML or any other optical

More information

Chapter 11 XML Data Modeling. Recent Development for Data Models 2016 Stefan Deßloch

Chapter 11 XML Data Modeling. Recent Development for Data Models 2016 Stefan Deßloch Chapter 11 XML Data Modeling Recent Development for Data Models 2016 Stefan Deßloch Motivation Traditional data models (e.g., relational data model) primarily support structure data separate DB schema

More information

Chapter 3 Brief Overview of XML

Chapter 3 Brief Overview of XML Slide 3.1 Web Serv vices: Princ ciples & Te echno ology Chapter 3 Brief Overview of XML Mike P. Papazoglou & mikep@uvt.nl Slide 3.2 Topics XML document structure XML schemas reuse Document navigation and

More information

Solution Sheet 5 XML Data Models and XQuery

Solution Sheet 5 XML Data Models and XQuery The Systems Group at ETH Zurich Big Data Fall Semester 2012 Prof. Dr. Donald Kossmann Prof. Dr. Nesime Tatbul Assistants: Martin Kaufmann Besmira Nushi 07.12.2012 Solution Sheet 5 XML Data Models and XQuery

More information

Proposal: Codelists 1.0 April 2003

Proposal: Codelists 1.0 April 2003 Proposal: Codelists 1.0 April 2003 Proposal: Codelists / 1.0 / April 2003 1 Document Control Abstract In many cases, there is a need to use sets of pre-defined codes (such as country and currency codes)

More information

XSLT Programming Constructs

XSLT Programming Constructs XSLT Programming Constructs Contents 1. Procedural programming in XSLT 2. Defining named template rules 3. Parameterizing XSLT style sheets 2 1. Procedural Programming in XSLT Declarative vs. procedural

More information

Advanced XQuery and XSLT

Advanced XQuery and XSLT NPRG036 XML Technologies Lecture 9 Advanced XQuery and XSLT 30. 4. 2018 Author: Irena Holubová Lecturer: Martin Svoboda http://www.ksi.mff.cuni.cz/~svoboda/courses/172-nprg036/ Lecture Outline XQuery Update

More information

Functions & Conditional Statements

Functions & Conditional Statements Functions & Conditional Statements OmniUpdate User Training Conference 2015 OmniUpdate, Inc. 1320 Flynn Road, Suite 100 Camarillo, CA 93012 OmniUpdate, Inc. 1320 Flynn Road, Suite 100 Camarillo, CA 93012

More information

XML and Semantic Web Technologies. II. XML / 5. XML Stylesheet Language Transformations (XSLT)

XML and Semantic Web Technologies. II. XML / 5. XML Stylesheet Language Transformations (XSLT) XML and Semantic Web Technologies XML and Semantic Web Technologies II. XML / 5. XML Stylesheet Language Transformations (XSLT) Lars Schmidt-Thieme Information Systems and Machine Learning Lab (ISMLL)

More information

Big Data for Engineers Spring Data Models

Big Data for Engineers Spring Data Models Ghislain Fourny Big Data for Engineers Spring 2018 11. Data Models pinkyone / 123RF Stock Photo CSV (Comma separated values) This is syntax ID,Last name,first name,theory, 1,Einstein,Albert,"General, Special

More information

Extensions to XSLT 1.0, and XSLT 2.0

Extensions to XSLT 1.0, and XSLT 2.0 ... Extensions A typical problem: XSLT 1.0 does not have any way of finding the current date and time. However, some XSLT 1.0 processors allow you to use extensions to XSLT 1.0. The EXSLT initiative http://www.exslt.org/

More information

XEP-0009: Jabber-RPC

XEP-0009: Jabber-RPC XEP-0009: Jabber-RPC DJ Adams mailto:dj.adams@pobox.com xmpp:dj@gnu.mine.nu 2011-11-10 Version 2.2 Status Type Short Name Final Standards Track jabber-rpc This specification defines an XMPP protocol extension

More information

Last week we saw how to use the DOM parser to read an XML document. The DOM parser can also be used to create and modify nodes.

Last week we saw how to use the DOM parser to read an XML document. The DOM parser can also be used to create and modify nodes. Distributed Software Development XML Schema Chris Brooks Department of Computer Science University of San Francisco 7-2: Modifying XML programmatically Last week we saw how to use the DOM parser to read

More information

On why C# s type system needs an extension

On why C# s type system needs an extension On why C# s type system needs an extension Wolfgang Gehring University of Ulm, Faculty of Computer Science, D-89069 Ulm, Germany wgehring@informatik.uni-ulm.de Abstract. XML Schemas (XSD) are the type

More information

Introduction to XSLT. Version 1.3 March nikos dimitrakas

Introduction to XSLT. Version 1.3 March nikos dimitrakas Introduction to XSLT Version 1.3 March 2018 nikos dimitrakas Table of contents 1 INTRODUCTION... 3 1.1 XSLT... 3 1.2 PREREQUISITES... 3 1.3 STRUCTURE... 3 2 SAMPLE DATA... 4 3 XSLT... 6 4 EXAMPLES... 7

More information

XML DTDs and Namespaces. CS174 Chris Pollett Oct 3, 2007.

XML DTDs and Namespaces. CS174 Chris Pollett Oct 3, 2007. XML DTDs and Namespaces CS174 Chris Pollett Oct 3, 2007. Outline Internal versus External DTDs Namespaces XML Schemas Internal versus External DTDs There are two ways to associate a DTD with an XML document:

More information

Presentation. Separating Content and Presentation Cascading Style Sheets (CSS) XML and XSLT

Presentation. Separating Content and Presentation Cascading Style Sheets (CSS) XML and XSLT Presentation Separating Content and Presentation Cascading Style Sheets (CSS) XML and XSLT WordPress Projects Theme Generators WYSIWYG editor Look at tools to support generation of themes Design a new

More information

COMP9321 Web Application Engineering. Extensible Markup Language (XML)

COMP9321 Web Application Engineering. Extensible Markup Language (XML) COMP9321 Web Application Engineering Extensible Markup Language (XML) Dr. Basem Suleiman Service Oriented Computing Group, CSE, UNSW Australia Semester 1, 2016, Week 4 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2442

More information

Author: Irena Holubová Lecturer: Martin Svoboda

Author: Irena Holubová Lecturer: Martin Svoboda A7B36XML, AD7B36XML XML Technologies Lecture 5 XML Schema 31. 3. 2017 Author: Irena Holubová Lecturer: Martin Svoboda http://www.ksi.mff.cuni.cz/~svoboda/courses/2016-2-a7b36xml/ Lecture Outline XML schema

More information

XML and XSLT. XML and XSLT 10 February

XML and XSLT. XML and XSLT 10 February XML and XSLT XML (Extensible Markup Language) has the following features. Not used to generate layout but to describe data. Uses tags to describe different items just as HTML, No predefined tags, just

More information

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

PASS4TEST. IT Certification Guaranteed, The Easy Way!   We offer free update service for one year PASS4TEST IT Certification Guaranteed, The Easy Way! \ http://www.pass4test.com We offer free update service for one year Exam : 000-141 Title : XML and related technologies Vendors : IBM Version : DEMO

More information

2006 Martin v. Löwis. Data-centric XML. XML Schema (Part 1)

2006 Martin v. Löwis. Data-centric XML. XML Schema (Part 1) Data-centric XML XML Schema (Part 1) Schema and DTD Disadvantages of DTD: separate, non-xml syntax very limited constraints on data types (just ID, IDREF, ) no support for sets (i.e. each element type

More information

Apache UIMA Regular Expression Annotator Documentation

Apache UIMA Regular Expression Annotator Documentation Apache UIMA Regular Expression Annotator Documentation Written and maintained by the Apache UIMA Development Community Version 2.3.1 Copyright 2006, 2011 The Apache Software Foundation License and Disclaimer.

More information

Manipulating XML Trees XPath and XSLT. CS 431 February 18, 2008 Carl Lagoze Cornell University

Manipulating XML Trees XPath and XSLT. CS 431 February 18, 2008 Carl Lagoze Cornell University Manipulating XML Trees XPath and XSLT CS 431 February 18, 2008 Carl Lagoze Cornell University XPath Language for addressing parts of an XML document XSLT Xpointer XQuery Tree model based on DOM W3C Recommendation

More information

Document erratum applies to QosDevice:1. List other Erratum s or Documents that this change may apply to or have associated changes with

Document erratum applies to QosDevice:1. List other Erratum s or Documents that this change may apply to or have associated changes with Erratum Number: Document and Version: Cross References: QosDevice:1 Erratum Next sequential erratum number Effective Date: July 14, 2006 Document erratum applies to QosDevice:1 List other Erratum s or

More information

Who s Afraid of XML Schema?

Who s Afraid of XML Schema? Who s Afraid of XML Schema? Neil Graham IBM Canada Ltd. Page Objectives Review some of the scariest aspects of XML Schema Focus on broad concepts Heavy use of examples Prove that the basics of XML Schema

More information

XSDs: exemplos soltos

XSDs: exemplos soltos XSDs: exemplos soltos «expande o tipo base»

More information

XSLT. December 16, 2008

XSLT. December 16, 2008 XSLT December 16, 2008 XML is used in a large number of applications, either data-centric (semi-structured databases), or document-centric (Web publishing). In either case, there is a need for transforming

More information

XPath Expression Syntax

XPath Expression Syntax XPath Expression Syntax SAXON home page Contents Introduction Constants Variable References Parentheses and operator precedence String Expressions Boolean Expressions Numeric Expressions NodeSet expressions

More information

CONVERTING CONCEPTUAL MODEL XUML TO XML SCHEMA

CONVERTING CONCEPTUAL MODEL XUML TO XML SCHEMA CONVERTING CONCEPTUAL MODEL XUML TO XML SCHEMA XUEMIN ZHANG School of Computer and Information Science, Hubei Engineering University, Xiaogan 432000, Hubei, China ABSTRACT As XML has become the standard

More information

Big Data Exercises. Fall 2018 Week 8 ETH Zurich. XML validation

Big Data Exercises. Fall 2018 Week 8 ETH Zurich. XML validation Big Data Exercises Fall 2018 Week 8 ETH Zurich XML validation Reading: (optional, but useful) XML in a Nutshell, Elliotte Rusty Harold, W. Scott Means, 3rd edition, 2005: Online via ETH Library 1. XML

More information

XPath and XSLT without the pain!

XPath and XSLT without the pain! XPath and XSLT without the pain! Bertrand Delacrétaz ApacheCon EU 2007, Amsterdam bdelacretaz@apache.org www.codeconsult.ch slides revision: 2007-05-04 Goal Learning to learn XPath and XSLT because it

More information

XML Technologies. Doc. RNDr. Irena Holubova, Ph.D. Web pages:

XML Technologies. Doc. RNDr. Irena Holubova, Ph.D. Web pages: XML Technologies Doc. RNDr. Irena Holubova, Ph.D. holubova@ksi.mff.cuni.cz Web pages: http://www.ksi.mff.cuni.cz/~holubova/nprg036/ Outline Introduction to XML format, overview of XML technologies DTD

More information

B oth element and attribute declarations can use simple types

B oth element and attribute declarations can use simple types Simple types 154 Chapter 9 B oth element and attribute declarations can use simple types to describe the data content of the components. This chapter introduces simple types, and explains how to define

More information

Pattern/Object Markup Language (POML): A Simple XML Schema for Object Oriented Code Description

Pattern/Object Markup Language (POML): A Simple XML Schema for Object Oriented Code Description Pattern/Object Markup Language (POML): A Simple XML Schema for Object Oriented Code Description Jason McC. Smith Apr 7, 2004 Abstract Pattern/Object Markup Language (or POML) is a simple XML Schema for

More information

Computer Science E-259

Computer Science E-259 Computer Science E-259 XML with Java Lecture 4: XPath 1.0 (and 2.0) and XSLT 1.0 (and 2.0) 21 February 2007 David J. Malan malan@post.harvard.edu 1 Computer Science E-259 Last Time DOM Level 3 JAXP 1.3

More information

The PCAT Programming Language Reference Manual

The PCAT Programming Language Reference Manual The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language

More information

Introduction to XSLT. Version 1.0 July nikos dimitrakas

Introduction to XSLT. Version 1.0 July nikos dimitrakas Introduction to XSLT Version 1.0 July 2011 nikos dimitrakas Table of contents 1 INTRODUCTION... 3 1.1 XSLT... 3 1.2 PREREQUISITES... 3 1.3 STRUCTURE... 3 2 SAMPLE DATA... 4 3 XSLT... 6 4 EXAMPLES... 7

More information

Big Data 9. Data Models

Big Data 9. Data Models Ghislain Fourny Big Data 9. Data Models pinkyone / 123RF Stock Photo 1 Syntax vs. Data Models Physical view Syntax this is text. 2 Syntax vs. Data Models a Logical view

More information

Presentation 19: XML technologies part 2: XSL, XSLT, XSL-FO, XPath & XML Programming

Presentation 19: XML technologies part 2: XSL, XSLT, XSL-FO, XPath & XML Programming Presentation 19: XML technologies part 2: XSL, XSLT, XSL-FO, XPath & XML Programming Outline XML recap Formatting CSS or XSL? XPath XSL/XSLT XSL-FO XML Programming Slide 2 XML markup recap XML based on

More information

Modelling XML Applications

Modelling XML Applications Modelling XML Applications Patryk Czarnik XML and Applications 2013/2014 Lecture 2 14.10.2013 XML application (recall) XML application (zastosowanie XML) A concrete language with XML syntax Typically defined

More information

Structured documents

Structured documents Structured documents An overview of XML Structured documents Michael Houghton 15/11/2000 Unstructured documents Broadly speaking, text and multimedia document formats can be structured or unstructured.

More information