FMS XML Class - PowerPoint PPT Presentation

1 / 204
About This Presentation
Title:

FMS XML Class

Description:

WAP/PDA. Reject / Return. XML-based reporting: DOD to Treasury. DOD. Treasury. DoD. Reporting System ... XML shall be compatible with SGML. ... – PowerPoint PPT presentation

Number of Views:85
Avg rating:3.0/5.0
Slides: 205
Provided by: CathyG60
Category:

less

Transcript and Presenter's Notes

Title: FMS XML Class


1
FMS XML Class
May 18-19, 2002
  • Nauman Malik
  • DFAS/XML Global

2
Outline
  • Business impetus
  • Collaboration between DFAS and FMS
  • Semantic alignment between Federal stakeholders
    w/ Treasury as data steward
  • (Project 1) Reporting Collaborative Components
  • (Project 2) MAF
  • XBRL
  • Technology vehicles (XML Related Technologies)
  • Approach (Validation via registry, MAF
    transformation)
  • Tools (XML Spy, XSL Tester, Transform, Registry)
  • XML, XML Schema, XSLT
  • Conclusion
  • FMS should now have the understanding of the
    technology involved to begin semantic alignment
    (w/ DFAS other partners)

3
Business impetus (Audience Business and
Technical)
4
Joint Treasury DFAS Collaborative XML
StrategyStandards-based Data Interchange Among
US Government Entities
Test Project Trial Balance Reports
5
Purpose
To start the process for defining a sound
financial data management strategy for the
federal government.
6
Example of Business Artifact / Collaborative
Component
United States Standard General Ledger Chart of
Accounts - XML Schema
lt?xml version"1.0" encoding"UTF-8"?gt lt!--
Created by Nauman Malik, DFAS --gt ltxsschema
targetNamespace"http//www.fms.treas.gov/namespac
es/SGLaccount" xmlnssglac"http//www.fms.treas.
gov/namespaces/SGLaccount" xmlnsxs"http//www.w
3.org/2001/XMLSchema" version"1.2"gt
ltxscomplexType name"SGLaccountType"gt
ltxsannotationgt ltxsdocumentationgtThe
datatypes for a general ledger account.
Device that sums financial business events.
This will provide the linkage to the
accounting descriptions of various reporting
entities. lt/xsdocumentationgt
lt/xsannotationgt ltxsallgt ltxselement
name"BalanceCode" type"sglacBalanceCodeType"/gt
ltxselement name"BalanceIndicatorCode"
type"sglacBalanceIndicatorCodeType"/gt ltxseleme
nt name"BeginningCalendarDate"
type"sglacBeginningCalendarDateType"/gt ltxselem
ent name"Code" type"sglacCodeType"/gt ltxseleme
nt name"EndingCalendarDate" type"sglacEndingCal
endarDateType"/gt ltxselement name"ID"
type"sglacIDtype"/gt ltxselement
name"JournalVoucherIndicatorCode"
type"sglacJournalVoucherIndicatorCodeType"/gt ltx
selement name"Name" type"sglacNameType"/gt ltxs
element name"PostedIndicatorCode"
type"sglacPostedIndicatorCodeType"/gt ltxselemen
t name"Text" type"sglacTextType"/gt ltxselement
name"FederalNonfederalCode" type"sglacFederalN
onfederalCodeType"/gt ltxselement
name"BudgetSubfunctionCode" type"sglacBudgetSub
functionCodeType"/gt ltxselement
name"CustodialNoncustodialCode"
type"sglacCustodialNoncustodialCodeType"/gt ltxs
element name"CapitalizedAcquisitionsCode"
type"sglacCapitalizedAcquisitionsCodeType"/gt ltx
selement name"TradingPartnerCode"
type"sglacTradingPartnerCodeType"/gt ltxselement
name"ExchangeNonexchangeCode"
type"sglacExchangeNonexchangeCodeType"/gt ltxsel
ement name"Amount" type"sglacAmountType"/gt
lt/xsallgt ltxsattribute name"uid"
type"xsstring"/gt lt/xscomplexTypegt
7
Test Project
  • Trial Balance Reports

8
Phase II Implementation
  • Create XML-based instance documents (for example,
    balance sheets) by extracting data from an RDBMS
    and DDRS application.

Phase III Collaboration
  • Building using Federal Government Financial
    Communitys collaborative business artifacts.

9
FACTS I Reporting Environment (w/ collaborative
components )
Components schema Repository
legend
Other CCs
SGL
Fund Group
Notes
XML Schema document
inherits from
XML instance document
inherits from
Non-XML data generator/ data store
Reporting System/ DB
FACTS I Report-Specific XML Schema
XSLT Stylesheet
Created, maintained, and provided by Treasury
Final Output
Extraction and conversion to XML
Web Server
validates
reside on
Web Browser (HTML)
Stylesheet 1
Stylesheet 2
Acrobat Reader (PDF)
FACTS I Report
Stylesheet 3
PDA/Cellphone (WML)
transformed by
resides on
Stylesheet 4
Excel Spreadsheet
Web Server/ Registry
reside on
10
Treasury
XML-based reporting DOD to Treasury
DOD
DDRS
XML
Schema
Transform/ validate
DFAS ACT
Parser
Treasury DB
Transform
Valid
Reject / Return
Invalid
11
XML-based reporting Treasury its Trading
Partners Integration Environment
Treasury Department
Repository / web server
Schemas / components
have access to
Reporting Departments
Transformations
Display
XML FACTS Report
Data
DoD Reporting System
Optional validation before submission
Validate and transform for DB storage
Library of Congress Reporting System
XML FACTS Report
Extract from DB
Transform Engine
Transform Engine
DB
Dept of Agriculture Reporting System
XML FACTS Report
Transform to XML
. . .
XML FACTS Report
intelligent querying
Reject if non-conformant
device of choice
13
12
(No Transcript)
13
DFAS
Distributed to all reporting organizations
MAF Template XSL
MAF Filter XSL
Edit XSL Template for appropriate DepartmentID
values
Treasury
XSLT Process
MAF XML
MAF DFAS XML
zipped
Transform
Oracle SDK
2
1
MAF Buffer
Application
MAF Flow
GET
GET
GET
14
XBRL Specification V.2
  • Courtesy
  • David vun Kannon, KPMG LLP
  • Specification Group Co-Chair

15
Fundamental Goals of XBRL
  • Transfer syntax for Financial Information
  • Throughout the value chain
  • Internal systems to Management
  • Company to Regulator
  • Company to Investor
  • Company to Capital Market
  • Archival representation of financial facts and
    concepts

16
Technical Approach of XBRL
  • XBRL is an XML language
  • XBRL builds on other XML specifications
  • XML Schema
  • XML Namespaces
  • XML Linking
  • XBRL can be processed by standard XML tools
  • DOM API
  • XSLT

17
Fundamental Design of XBRL
  • Financial information is worthless without proper
    context.
  • What is the meaning of 7?
  • The most important piece of context What
    concept are we measuring.
  • What does operating income mean?
  • Whose definition of that concept?
  • AICPA, IASB, SEC? Company specific?

18
Fundamental Design of XBRL
  • A bag of financial facts
  • Financial facts are independent of each other.
  • This is the XBRL instance document.
  • A bag of financial concepts
  • The set of definitions used by the facts.
  • Concepts are interrelated in many ways.
  • This is the XBRL taxonomy document
  • One instance document usually uses several
    taxonomy documents.

19
XML Related Technologies (Audience Technical
and Business-Technical)
20
Course Overview
  • XML
  • Information Modeling
  • XML Schema
  • XSLT

21
XML
  • Introduction to XML
  • Applications of XML
  • XML Related Technologies
  • XML Syntax

22
Introduction to XML
  • What is XML?
  • What were the goals of its design?

23
Summary Slide
  • What is XML?
  • XML - Labeling Data
  • XML - Organizing Data
  • Design Goals for XML

24
What is XML?
  • eXtensible Markup Language
  • Formatted DATA - label and organize
  • Not a programming language

25
XML - Labeling Data
  • Applications can't use unlabeled data efficiently
  • Applications CAN use LABELED data efficiently

car
Camry
Camry
4Runner
suv
4Runner
Corolla
car
Corolla
26
XML - Organizing Data
  • Data is organized in a hierarchical tree

27
Design Goals for XML
  • XML documents should be human-legible and
    reasonably clear.
  • XML documents shall be easy to create.
  • The design of XML shall be formal and concise.
  • Terseness in XML markup is of minimal importance

28
Design Goals of XML con't
  • XML shall be compatible with SGML.
  • The number of optional features in XML is to be
    kept to the absolute minimum, ideally zero.
  • The XML design should be prepared quickly.

29
Design Goals of XML con't
  • XML shall be straightforwardly usable over the
    Internet.
  • XML shall support a wide variety of applications
  • It shall be easy to write programs which process
    XML documents.

30
Applications of XML
  • What are some uses of XML?
  • Business Case Scenarios

31
Summary Slide
  • Data Mining
  • Content Reusability
  • Transformations
  • Application Integration
  • B2B
  • Value Proposition
  • Business Case Scenarios

32
Data Mining
  • Querying for specific information
  • Extracting data according to the tag name (label)
  • ltcargtCamrylt/cargt

car
Camry
33
Content Reusability
Flat File (EDI)
XML File
DTM00220000928! PO1AAA849100! QTY28.500!
AMTFL50.00D!
ltDategt20000928lt/Dategt ltPOgt100lt/POgt ltQuantitygt.
500lt/Quantitygt ltAmountgt50.00lt/Amountgt
34
Transformations
  • Filtered views (via searches)
  • File representations of data (ie PDF)
  • Browser viewable versions (multiple)

35
Application Integration
  • Easy to learn / maintain
  • Human readable
  • Defined structure and hierarchy
  • Useful tools for building infrastructure and
    translating into proprietary systems
  • Open standard

36
B2B
  • Custom Markup Languages can be created to address
    specific exchange needs
  • Conformance to the standard ensures
    interoperablility of data
  • Provides a common standard for integration into
    backend systems

37
Value Proposition
  • Increased speed to market
  • Lower information exchange barrier
  • Fluid information exchange among trading partners
  • Streamlined business processes

38
Business Case Scenarios
  • Scenario 1
  • Business Partnerships

39
Business Partnerships (before)
Converters
SAP
Oracle
Loan Processing Company
People Soft
Car Dealership
SAP
Banks
40
Business Partnerships (leveraging XML)
Interpreters
SAP
Oracle
Loan Processing Company
XML
XML
People Soft
Car Dealership
SAP
Banks
41
Business Partnerships (XML enhancing EDI)
EDI
S Region
SAP
Major Grocery Chain Headquarters
N Region
EDI 879
Fax
Independent Outlet
Major Distributor
Email
Independent Outlet
Outlets
Converters
42
Business Partnerships (XML enhancing EDI)
Interpreters
S Region EDI
N Region SAP
Major Grocery Chain Headquarters
EDI 879
XML
Independent Outlet Browser Version
Major Distributor
Independent Outlet Browser Version
Outlets
43
Business Case Scenarios
  • Scenario 2
  • Government Agency

44
Content ReusabilityData Longevity
Information Repository
Inner Departmental Agency
Government Agency
Person with Query
45
XML Related Technologies
  • What are the technologies surrounding XML?

46
Summary Slide
  • Definition of Documentsand Structure
  • Processing and Transformation
  • Rendering XML
  • Linking and Querying XML

47
Definition of Documentsand Structure
XML
Namespaces
48
Definition of Documentsand Structure
DTD
XMLSchema
49
Processing and Transformation
SAX
DOM
50
Processing and Transformation
XSLT
51
Rendering XML
XHTML
XSL
52
Linking and Querying XML
XPath
XMLQuery
53
Linking and Querying XML
XLink
XPointer
54
XML Syntax
  • Well-Formed Documents
  • Namespaces

55
Summary Slide
  • Structure and SyntaxParagraph Analogy
  • Basic XML Components
  • Pre-defined Entities
  • XML Structure and SyntaxWell-Formed XML
    Documents
  • Namespaces

56
Structure and SyntaxParagraph Analogy
  • Essays contain paragraphs
  • Paragraphs contain sentences
  • Sentences contain words
  • Sentences
  • start with a capital letter
  • end with a punctuation mark
  • etc

57
Basic XML Components
  • XML Declaration
  • Processing Instruction
  • Element
  • Empty Element
  • Attribute
  • Comment
  • CDATA Section

58
XML Declaration and Processing Instructions (PIs)
lt?xml version"1.0" ?gt lt?xml-stylesheet
href"book.css" ?gt
  • XML Declaration
  • optional
  • must begin on row 1, col 1
  • Processing Instructions
  • have name and data
  • are instructions to applications

59
Elements and Attributes
  • Elements
  • Backbone of the document
  • Contain main document content
  • One root element
  • Elements delimited with 'lt' and 'gt'
  • Empty elements may have special syntax
  • Attributes
  • value is quoted (' or ")
  • further describe the element
  • ltbookInventorygt
  • ltbook qty"1000"gt
  • lttitlegt
  • Go,Dog,Go
  • lt/titlegt
  • ltisbn num"1234"/gt
  • lt/bookgt
  • lt/bookInventorygt

60
Comments, CDATA Sections
  • ltbookInventorygt
  • lt!-- book list --gt
  • ltinventoryIDgt
  • lt!CDATA12YE76gt
  • lt/inventoryIDgt
  • lt/bookInventorygt
  • Comments
  • do not nest
  • can be at top, bottom, or inside document
    element
  • CDATA Sections
  • unparsed section
  • 'passed thru' to application

61
Basic XML Components - Review
  • XML Declaration
  • Processing Instruction
  • Element
  • Empty Element
  • Attribute
  • Comment
  • CDATA Section
  • lt?xml version"1.0" ?gt
  • lt?xml-stylesheet href"book.css"?gt
  • ltbookInventorygt
  • lt!-- children's books --gt
  • ltbook qty"1000"gt
  • ltisbn number"1234" /gt
  • lttitlegtGo, Dog, Golt/titlegt
  • ltauthorgtDr. Seusslt/authorgt
  • ltinventoryIDgt
  • lt!CDATA12YE76gt
  • lt/inventoryIDgt
  • lt/bookgt
  • lt/bookInventorygt

62
Pre-defined Entities
  • parser input
  • lt?xml version"1.0" ?gt
  • lttest a1"lthellogt"gt lthellogt
  • lt!CDATAlthellogtgt
  • lt/testgt
  • parser (logical) output
  • lttest a1"lthellogt"gt
  • lthellogt
  • lthellogt
  • lt/testgt

63
XML Structure and SyntaxWell-Formed XML Documents
  • Only one root element
  • Proper Element Nesting
  • Every start tag has an end tag
  • Attribute values must be quoted ('a' or "a")
  • Naming Requirements (elements and attributes)
  • start with letter, _ ,
  • followed by letter, digit, _ , - , , .
  • cannot start with 'xml'

64
Namespaces
  • Namespaces allow authors and programmers to
    disambiguate names
  • Allow individual documents to contain multiple
    vocabularies

65
Building from Multiple Vocabularies
Book Inventory Vocabulary bookinventory book title
Purchase Order Vocabulary po name shipTo
ltpogt ltnamegt ltshipTogt ltbookgt lttitlegt..
lt/titlegt
XML document with mixed vocabularies
66
Namespace Example 1
  • ltpo xmlns"urnPurchaseOrder"
  • xmlnsbk"urnBookInventory" gt
  • ltnamegtTomlt/namegt
  • ltshipTogtXML Globallt/shipTogt
  • ltbkbookgt
  • ltbktitlegtGo,Dog,Golt/bktitlegt
  • ltbkauthorgtDr. Seusslt/bkauthorgt
  • lt/bkbookgt
  • lt/pogt

67
Namespace Example 2
  • ltpurpo xmlnspur"urnPurchaseOrder"
  • xmlnsbk"urnBookInventory" gt
  • ltpurnamegtTomlt/purnamegt
  • ltpurshipTogtXML Globallt/purshipTogt
  • ltbkbookgt
  • ltbktitlegtGo,Dog,Golt/bktitlegt
  • ltbkauthorgtDr. Seusslt/bkauthorgt
  • lt/bkbookgt
  • lt/purpogt

68
Information Modeling
  • Introduction to Information Modeling
  • Information Modeling Languages

69
Introduction to Information Modeling
  • How to verify the vocabulary, structure, and
    content of an XML document

70
Summary Slide
  • Well-formed XML (Correct Syntax)
  • What do Information Models (Schemas) Define?
  • What is a Valid XML Document?
  • Why Have an Information Model

71
Well-formed XML (Correct Syntax)
  • ltbook qty"1000"gt
  • lttitlegt
  • Go, Dog, Go
  • lt/titlegt
  • ltauthorgt
  • Dr. Suess
  • lt/authorgt
  • lt/bookgt
  • ltBookgt
  • ltqtygt1000lt/qtygt
  • lttitlegt
  • Go, Dog, Go
  • lt/titlegt
  • ltauthorgt
  • Dr. Suess
  • lt/authorgt
  • lt/Bookgt

72
What do Information Models (Schemas) Define?
  • Allowed names of elements and attributes
    (vocabulary)
  • Types of content
  • Hierarchical structure

73
Sample Information Model
74
What is a Valid XML Document?
  • An xml document that conforms to its information
    model is VALID in terms of
  • vocabulary (correct words)
  • structure (correct place)
  • content (correct type of data)

75
Valid XML Document
  • ltbook qty"1000"gt
  • lttitlegt
  • Go, Dog, Go
  • lt/titlegt
  • ltauthorgt
  • Dr. Suess
  • lt/authorgt
  • lt/bookgt

76
Invalid XML Document
  • ltBookgt
  • ltqtygt1000lt/qtygt
  • lttitlegt
  • Go, Dog, Go
  • lt/titlegt
  • ltauthorgt
  • Dr. Suess
  • lt/authorgt
  • lt/Bookgt

77
Well-Formed and Valid XML
  • A valid document is always well-formed, but the
    reverse is not always true.

78
Why Have an Information Model?
  • Standardizing a type of XML document
  • Programs can ensure the XML to be processed is in
    the correct form
  • Programmers, authors, and analysts can base their
    work on the same information model

79
Information Modeling Languages
  • Different languages that can be used for xml
    information modeling

80
Summary Slide
  • XML Information Modeling Languages
  • Document Type Definition (DTD)
  • Information Modeling in XML Syntax
  • XML Schema
  • Comparing Element Declarations

81
XML Information Modeling Languages
  • DTD
  • XDR
  • SOX
  • XML Schema

82
Document Type Definition (DTD)
  • W3C standard for XML information modeling
  • Derived from SGML DTD syntax
  • Builds on pre-existing SGML experience and
    parsing technology
  • Concise, non-XML syntax
  • All data treated as text

83
Information Modeling in XML Syntax
  • XDR, SOX, XML Schema
  • Object oriented features
  • Definition of types
  • Inheritance
  • Types map to objects
  • Types are reusable

84
XML Schema
  • Information modeling language for XML developed
    by W3C
  • Incorporates ideas from SOX and XDR
  • Full support for datatypes
  • Built in types (integer, boolean, etc.)
  • Custom types (telephone numbers, etc.)

85
Comparing Element Declarations
  • Differences in data typing and syntax

86
XML Schema
  • XML Schema Overview
  • XML Schema Simple Types
  • XML Schema Complex Types
  • XML Schema Component Reuse

87
XML Schema Overview
  • XML Schema Features
  • Namespaces

88
Summary Slide
  • Features
  • XML Schema vs. DTD
  • Components
  • Basic Element Declaration
  • Namespaces
  • Example

89
XML Schema Terminology
  • XML Schema
  • The Schema spec, defined and maintained by the
    W3C
  • XML Schema Primer
  • XML Schema Structures
  • XML Schema Datatypes
  • XML Schemas
  • Documents defined and maintained by
  • users
  • organizations
  • industries

90
XML Schema Features
  • Datatype Validation
  • integers, time, date, boolean, ..
  • User-defined types (extension or restriction)
  • Open or closed content models
  • Groups, Attribute Groups
  • Namespace support
  • Written in XML Syntax
  • Object Oriented

91
XML Schema vs. DTD
  • XML Schema
  • Datatype Validation
  • XML syntax
  • Object Oriented
  • Namespace support
  • 2k thing
  • DTD
  • no
  • Custom syntax
  • no
  • no
  • 80's thing

92
Primary Schema Components
  • Element Declarations
  • Attribute Declarations
  • Simple Type Definitions
  • Complex Type Definitions

93
Secondary Schema Components
  • Model Group Definitions
  • Attribute Group Definitions
  • Identity-constraint Definitions
  • Notations Declarations
  • Wildcards
  • Annotations

94
Instance Document
  • book.xml
  • lt?xml version"1.0"?gt
  • ltbookgt
  • Go, Dog, Go
  • lt/bookgt

95
Basic Element Declaration
  • book.xsd
  • ...
  • ltelement name"book" type"string" /gt
  • ...
  • book.dtd (equivalent)
  • ...
  • lt!ELEMENT book (PCDATA) gt
  • ...

Element Declarations
96
XML Schema ExampleNo Target Namespace
  • book.xml
  • ltbook xmlnsxsi
  • "http//www.w3.org/2000/10/XMLSchema-instance"
  • xsinoNamespaceSchemaLocation"book.xsd" gt
  • Go, Dog, Golt/bookgt
  • book.xsd
  • ltxsdschema xmlnsxsd
  • "http//www.w3.org/2000/10/XMLSchema"gt
  • ltxsdelement name"book" type"xsdstring" /gt
  • lt/xsdschemagt

97
XML Schema Namespaces
Schema NS
Schema Instance NS
Target NS
string element
book
schemaLocation
creates new target namespace
user.xsd
user.xml
uses names from XML Schema namespace
uses names from target namespace and schema
instance namespace
98
XML Schema ExampleWith Target Namespace
  • book.xsd
  • ltxsdschema xmlnsxsd
  • "http//www.w3.org/2000/10/XMLSchema"
  • targetNamespace"http//www.company.com"
  • xmlns"http//www.company.com" gt
  • ltxsdelement name"book" type"xsdstring"/gt
  • lt/xsdschemagt

99
XML Schema ExampleWith Target Namespace Con't
  • book.xml
  • lt?xml version"1.0" ?gt
  • ltbook xmlnsxsi
  • "http//www.w3.org/2000/10/XMLSchema-instance"
  • xsischemaLocation
  • "http//www.company.com book.xsd"
  • xmlns"http//www.company.com" gt
  • Go, Dog, Go
  • lt/bookgt

100
XML Schema SimpleTypes
  • Built-In SimpleTypes
  • User Defined SimpleTypes

101
Summary Slide
  • SimpleType Usage
  • Built-In SimpleTypes
  • User-defined SimpleTypes
  • Named and Anonymous Type Definitions

102
SimpleType Usage
  • SimpleTypes are used for
  • Text only element content
  • Attribute content
  • SimpleTypes allow data type validation
  • integer, boolean, date, ..

103
Common Built-In SimpleTypes
  • Type
  • string
  • boolean
  • float
  • date
  • time
  • binary
  • integer, negative-integer
  • uri-reference
  • XML 1.0 attribute types
  • and more
  • Sample Content
  • hello
  • true,false,1,0
  • 1.34 (single precision)
  • 2000-02-25
  • 132000
  • 01001000
  • 123,-123
  • http//www.xmlglobal.com
  • (ID, IDREF,NMTOKEN)
  • and more

104
Using Built-In SimpleTypesSchema Document
  • address.xsd
  • ltxsdschema namespace info gt
  • ...
  • ltxsdelement name"name" type"xsdstring"/gt
  • ltxsdelement name"street" type"xsdstring"/gt
  • ltxsdelement name"zip" type"xsdinteger"/gt
  • ...
  • lt/xsdschemagt

105
Using Built-In SimpleTypesInstance Document
  • address.xml
  • lt?xml version1.0 ?gt
  • ...
  • ltnamegtTom Smithlt/namegt
  • ltstreetgt123 Main Streetlt/streetgt
  • ltzipgt20141lt/zipgt
  • ...

106
User-defined SimpleTypesRestricting Content -
Facets
  • length
  • minlength
  • maxlength
  • pattern
  • enumeration
  • maxInclusive
  • maxExclusive
  • minInclusive
  • minExclusive
  • precision
  • scale
  • encoding
  • period

107
User-defined SimpleType
  • Restrict the content to ddd-dd
  • Instance document

usertypes.xml lt?xml version"1.0"
?gt ... ltpartNumgt345-43lt/partNumgt ...
108
User-defined SimpleTypeNamed Type Definition
  • usertypes.xsd
  • ...
  • ltxsdsimpleType name"Sku" gt
  • ltxsdrestriction base"xsdstring" gt
  • ltxsdpattern value"/d3-/d2" /gt
  • lt/xsdrestrictiongt
  • lt/xsdsimpleTypegt
  • ltxsdelement name"partNum" type"Sku"/gt
  • ...

type definition
element declaration
109
User-defined SimpleTypeAnonymous Type Definition
  • usertypes.xsd
  • ...
  • ltxsdelement name"partNum"gt
  • ltxsdsimpleTypegt
  • ltxsdrestriction base"xsdstring" gt
  • ltxsdpattern value"/d3-/d2" /gt
  • lt/xsdrestrictiongt
  • lt/xsdsimpleTypegt
  • lt/xsdelementgt
  • ...

type definition
element declaration
110
Using the enumeration Facet
  • customtypes.xsd
  • ...
  • ltxsdsimpleType name"US-State" gt
  • ltxsdrestriction base"xsdstring"gt
  • ltxsdenumeration value"AK"/gt
  • ltxsdenumeration value"AL"/gt
  • lt!-- and so on ... --gt
  • lt/xsdrestrictiongt
  • lt/xsdsimpleTypegt
  • ltxsdelement name"state" type"US-State"/gt
  • ...

type definition
element declaration
111
XML Schema Complex Types
  • Complex Type Definitions
  • Attribute Declarations

112
Summary Slide
  • Simple Types vs. Complex Types
  • Named and Anonymous Complex Type
  • Multiple Occurrence of Elements
  • Attribute Declarations

113
Simple Types vs. Complex Types
  • SimpleTypes
  • attributes
  • text-only elements
  • ComplexTypes
  • elements with attributes
  • elements with element (or mixed) content

114
Sample Instance Document
  • ltaddressgt
  • ltnamegtTomlt/namegt
  • ltstreetgt
  • Main St
  • lt/streetgt
  • ltzipgt20141lt/zipgt
  • lt/addressgt
  • complex type
  • ltaddressgt
  • simple type
  • ltnamegt
  • ltstreetgt
  • ltzipgt

115
The Schema DocumentNamed Complex Type
  • ltxsdschema ..namespace info.. gt
  • ltxsdelement name"address" type"AddressType"/gt
  • ltxsdcomplexType name"AddressType" gt
  • ltxsdsequencegt
  • ltxsdelement name"name" type"xsdstring" /gt
  • ltxsdelement name"street" type"xsdstring"/gt
  • ltxsdelement name"zip" type"xsdinteger" /gt
  • lt/xsdsequencegt
  • lt/xsdcomplexTypegt
  • lt/xsdschemagt

116
The Schema DocumentAnonymous Complex Type
  • ltxsdschema ..namespace info.. gt
  • ltxsdelement name"address"/gt
  • ltxsdcomplexTypegt
  • ltxsdsequencegt
  • ltxsdelement name"name" type"xsdstring" /gt
  • ltxsdelement name"street" type"xsdstring"/gt
  • ltxsdelement name"zip" type"xsdinteger" /gt
  • lt/xsdsequencegt
  • lt/xsdcomplexTypegt
  • lt/xsdelementgt
  • lt/xsdschemagt

117
Multiple Occurrence of Elements
  • ltxsdschema ..namespace info.. gt
  • ltxsdelement name"address"
  • minOccurs"1" maxOccurs"unbounded"gt
  • ltxsdcomplexTypegt
  • ...
  • ltxsdelement name"street" type"xsdstring"
  • minOccurs"1" maxOccurs"2" /gt
  • ...
  • lt/xsdcomplexTypegt
  • lt/xsdelementgt
  • lt/xsdschemagt

118
Adding in Attributes
  • Must add
  • attribute declaration
  • Must modify
  • type definition
  • ltaddress location"home"gt
  • ltnamegtTomlt/namegt
  • ltstreetgt
  • Main St
  • lt/streetgt
  • ltzipgt20141lt/zipgt
  • lt/addressgt

119
Schema Documentwith Attributes
  • ltxsdelement name"address" type"AddressType"/gt
  • ltxsdcomplexType name"AddressType" gt
  • ltxsdsequencegt
  • ltxsdelement name"name" type"xsdstring" /gt
  • ...
  • lt/xsdsequencegt
  • ltxsdattribute name"location"
    type"xsdstring"/gt
  • lt/xsdcomplexTypegt

120
Attribute Declaration Modifiers
  • Optional or Required
  • ltxsdattribute name"w" type"xsdstring"
  • use"optional" /gt
  • ltxsdattribute name"x" type"xsdstring"
  • use"required" /gt
  • Fixed or Default Values
  • ltxsdattribute name"x" type"xsdinteger"
  • use"fixed" value"32" /gt
  • ltxsdattribute name"x" type"xsdinteger"
  • use"default" value"32" /gt

121
XML Schema Component Reuse
  • References
  • Groups

122
Summary Slide
  • XML Schema Reuse Possibilities
  • Declaration References
  • Model Groups
  • Attribute Groups

123
XML Schema Reuse Possibilities
  • Type Definitions
  • globally-defined named types
  • Element Declarations
  • element references
  • Content Model Fragments
  • model groups
  • Attribute Declarations
  • attribute groups, attribute references

124
Instance Document
  • ...
  • lta r"55" s"23" gt
  • ltx/gtlty/gtltz/gt
  • lt/agt
  • ltb r"66" s"45"gt
  • ltx/gtlty/gt
  • lt/bgt
  • ...

125
DTD Sample
  • lt!ELEMENT a ( (x,y),(wz) ) gt
  • lt!ATTLIST a r CDATA IMPLIED
  • s CDATA IMPLIED gt
  • lt!ELEMENT b ( (x,y)(w,z) ) gt
  • lt!ATTLIST b r CDATA IMPLIED
  • s CDATA IMPLIED gt
  • lt!ELEMENT x (PCDATA) gt
  • lt!ELEMENT y (PCDATA) gt
  • lt!ELEMENT w (PCDATA) gt
  • lt!ELEMENT z (PCDATA) gt

126
Global Element Declarations
  • ltxsdschema ..namespace info..gt
  • ltxsdelement name"x" type"xsdstring" /gt
  • ltxsdelement name"y" type"xsdstring" /gt
  • ltxsdelement name"w" type"xsdstring" /gt
  • ltxsdelement name"z" type"xsdstring" /gt
  • ...cont'd

127
Element Declaration Referencesand Model Groups
  • ...
  • ltxsdgroup name"xyGroup"gt
  • ltxsdsequencegt
  • ltxsdelement ref"x" /gt
  • ltxsdelement ref"y" /gt
  • lt/xsdsequencegt
  • lt/xsdgroupgt
  • ...
  • Equivalent to
  • '(x,y)'
  • in the DTD

128
XML Schema DocumentAttribute Groups
  • ..
  • ltxsdattributeGroup name"rsAttrGroup"gt
  • ltxsdattribute name"r" type"xsdinteger" /gt
  • ltxsdattribute name"s" type"xsdinteger" /gt
  • lt/xsdattributeGroupgt
  • ..

129
XML Schema DocumentPutting it Together - Element
a
  • ltxsdelement name"a"gt
  • ltxsdcomplexTypegt
  • ltxsdsequencegt
  • ltxsdgroup ref"xyGroup"/gt
  • ltxsdgroupgt
  • ltxsdchoicegt
  • ltxsdelement ref"w" /gt
  • ltxsdelement ref"z" /gt
  • lt/xsdchoicegt
  • lt/xsdgroupgt
  • lt/xsdsequencegt
  • ltxsdattributeGroup ref"rsAttrGroup"/gt
  • lt/xscomplexTypegt
  • lt/xsdelementgt

130
XML Schema DocumentPutting it Together - Element
b
  • ltxsdelement name"b"gt
  • ltxsdcomplexTypegt
  • ltxsdchoicegt
  • ltxsdgroup ref"xyGroup"/gt
  • ltxsdgroupgt
  • ltxsdsequencegt
  • ltxsdelement ref"w" /gt
  • ltxsdelement ref"z" /gt
  • lt/xsdsequencegt
  • lt/xsdgroupgt
  • lt/xsdchoicegt
  • ltxsdattributeGroup ref"rsAttrGroup"/gt
  • lt/xscomplexTypegt
  • lt/xsdelementgt

131
XSLT
  • Introduction to XSLT
  • XPath Data Model
  • XPath Expressions
  • XSLT Transformation Basics
  • XSLT Instructions
  • XPath Functions
  • XSL

132
Introduction to XSLT
  • Transformation Options

133
Summary Slide
  • The Need for Transformation
  • Transformation Possibilities
  • Transforming XML
  • XSLT Flexibility
  • Server vs. Client-side Transformation

134
The Need for Transformation
  • ltcoursegtlttitlegtXSLTlt/titlegt
  • lttopicgt
  • lttitlegtIntroductionlt/titlegt
  • ltslidegtlttitlegtWhy XSLT?lt/titlegtlt/slidegt
  • lt/topicgt
  • lt/coursegt
  • XML files usually contain data content only,
  • not presentation info.
  • Something else is needed to provide presentation
    semantics.

135
Transformation Possibilities
  • Content only documents into presentation
  • XML to HTML
  • XML to XHTML
  • XML to PDF, SVG, SMIL
  • General purpose XML to XML transformations
  • B2B
  • Inter-process communication
  • XML to other formats (text, CSV, )

136
Transforming XML
UI, browser, html, etc..
  • Programmers can transform XML into presentation
    with various programming languages

parser
XML content
JavaScript Java VB C
Presentation
137
Transforming XML
  • The design of these programs are similar
  • when a node of type lttitlegt is encountered,
    convert to 12 pt TimesRoman, red, bold
  • when a node of type is encountered, convert to
  • It should be possible to use a higher-level
    declarative language to define the transform
    thats what XSLT is all about

138
How XSLT works
  • XSLT is a high-level declarative language for
    transforming the structure of an XML document
    into other formats
  • XSLT document has transformation instructions
  • XSLT engine executes the instructions

XML
XML parser
html
XSLT Engine
XSLT
139
XSLT Transformation
q
transformation
XML
s
r
x
x
filtering
z
y
XML parser
z
XSLT engine
x
sorting
XSLT
XSLT can transform both attributes AND elements.
y
z
x
adding
y
z
y
z
140
XSLT Flexibility
X1
  • A stylesheet can be
  • used for more than
  • one source document
  • A source document can
  • be transformed with more
  • than one stylesheet

S
X2
X2
X3
S
X
S
S
141
Server vs. Client-side Transformation
XML-Enabled Browser
XML
XSLT Engine
Display

XSLT
Older Browser
XSLT Engine
XML
Display

XSLT
Client-side
Server-side
142
XPath Data Model
  • Node Trees

143
Summary Slide
  • Overview of XPath
  • XPath Data Model
  • Sample XML Document and Node Tree
  • Node Properties

144
Overview of XPath
  • A language for addressing parts of an XML
    document
  • XML document modeled as a tree of nodes
  • Used extensively in XSLT and XPointer
  • Enables queries of XML documents
  • Provides for manipulation of strings, numbers,
    and booleans

145
XPath Data Model
  • Seven Types of Nodes

text
root
comment
processing
attribute
element
instruction
namespace
146
Sample XML Document
  • lt?xml version1.0?gt
  • ltbook pages262 pub_date1998gt
  • lt!- good book! --gt
  • lttitlegtIs the Temperature Risinglt/titlegt
  • ltauthorgtS. George Philanderlt/authorgt
  • lt/bookgt

147
Corresponding XPath Node Tree
/
root
year
pages
book
"1998"
"246"
element
attribute
title
good book
author
text
"Is the
comment
"S. George
Temperature
Philander"
Rising?"
Node Type
148
Node Properties Names and String-values
  • A string-value can be computed for every node
    type
  • The following node types have names
  • Elements
  • Attributes
  • Namespaces
  • Processing Instructions

149
Names and String-values of Select Node Types
150
Names and String-values of Select Node Types
151
XPath Expressions
  • Location Paths

152
Summary Slide
  • XPath Expressions
  • Location Path
  • Location Steps
  • XPath Axes
  • Node Tests
  • Predicates

153
XPath Expressions
  • XPath is constructed from expressions
  • Types of expressions
  • Location paths
  • Function calls
  • Expressions are evaluated relative to a context
    node

154
Location Path
/
  • Address of node(s) in tree
  • If context node root node

a
x "hi"
b
f
g
c
c
c
"yes"
"3"
"2"
"1"
155
Location Steps
  • Location paths are made up of location steps
  • Steps are separated by /
  • a/f/g ? Step/Step/Step

156
Location Step Syntax
  • The full syntax of a step is
  • childchapter3
  • axis nodetest predicate

157
XPath Axes
  • If 'F' is the context node
  • self gt F
  • parent gt C
  • ancestor gt A, C
  • child gt H, I, J
  • descendant
  • gt H, I, J, K, L, M

158
Axis Abbreviations
chapter/_at_page is childchapter/attributepage ..
/author is parentnode()/childauthor
159
Node Tests
  • Used to identify nodes in axis by name or type.
  • By Name
  • chapter
  • selects child chapter nodes of the context node
  • OReillybook
  • selects book child nodes in the OReilly namespace
  • By Type
  • para/text()
  • selects all child text nodes of para element
  • workitem/node()
  • selects all nodes that are children of workitem
    element

160
Predicates
  • Further qualifies a node set returned in a step
  • Enclosed in and
  • In evaluation, context node changes as each
    predicate is applied
  • If more than one, evaluated left to right
  • orderitem3
  • selects third orderitem child element of context
    node

161
Predicate Examples
  • orderitemcomputer/_at_typelaptop
  • selects orderitem children of the context node
    with computer children whose type attribute value
    is laptop
  • orderitem_at_statusrush2
  • selects second orderitem child of context node
    whose status attriute has value rush
  • orderitem2_at_statusrush
  • selects second orderitem child of context node if
    its status attribute has the value rush

162
Transformation Basics
  • XSLT Engine Processing

163
Summary Slide
  • Processing Introduction
  • XSLT Namespace
  • Current Node and Current Node List
  • xslapply-templates
  • xsltemplate
  • Built-in Templates
  • Example (XML to HTML)

164
Processing Introduction Example, File View
Input
Desired Output
XML ltagthellolt/agt
XML ltxgthellolt/xgt
XSLT Engine
  • By convention,
  • xslt transform files
  • have an .xsl extension

XSLT (.xsl file)
165
Processing Introduction Example, File View
in.xml ltagthellolt/agt
out.xml ltxgthellolt/xgt
XSLT Engine
myTransform.xsl lt?xml version"1.0"
?gt ltxslstylesheet version"1.0"
xmlnsxsl"http//www.w3.org/1999/XSL/Transform"gt
ltxsltemplate match"/"gt ltxgt
ltxslvalue-of select"a"/gt lt/xgt
lt/xsltemplategt lt/xslstylesheetgt
166
XSLT Namespace
  • myTransformation.xsl
  • lt?xml version"1.0" ?gt
  • ltxslstylesheet xmlnsxsl"http//www.w3.org/1999/
    XSL/Transform"gt
  • ltxsltemplate match"/"gt
  • ltxgt
  • ltxslvalue-of select"a"/gt
  • ...
  • Commonly, "xsl" is used to identify the XSLT
    vocabulary
  • No resource at the url listed, it is just a
    namespace identifier

167
Processing IntroductionExample, Node View
/
x
ltxgthellolt/xgt
a
XML parser
hello
XML
hello
XSLT Engine
stylesheet
template
"/"
XSL
  • Note use of
  • namespaces

x
value-of
"a"
168
Current Node and Current Node List
(current node list)
(current node)
  • XSLT Engine Processing
  • Starts at the document
  • node ('/' node), checks all
  • template rules for a match,
  • then processes that template into the result
    tree.
  • Processing continues depending on the
    instructions found.
  • XSLT Engine keeps track of the 'current node',
    and
  • the 'current node list'.

/
(document node)
a
hello
169
xslapply-templates
  • Creates a list of nodes for processing by waiting
    templates, in document order
  • Examples
  • Process all child nodes
  • ltxslapply-templates/gt
  • Process only the ltnamegt nodes
  • ltxslapply-templates select"name"/gt

170
xsltemplate
  • A template is a top-level element in a
    stylesheet. Once the template is chosen to be
    executed by the engine, the body of the template
    generates nodes into the result tree.
  • ltxsltemplate match"XPath expression"gt
  • .. template body here ..
  • lt/xsltemplategt

171
Built-in Templates
  • Built-in templates exist but can be overridden
  • For root/element nodes
  • ltxsltemplate match" /"gt
  • ltxslapply-templates/gt
  • lt/xsltemplategt
  • For text/attribute nodes
  • ltxsltemplate match"text() _at_"gt
  • ltxslvalue-of select"."/gt
  • lt/xsltemplategt

172
Example (XML to HTML)Input document
  • lt?xml version1.0?gt
  • ltauthorsgt
  • ltnamegtJoe Smithlt/namegt
  • ltnamegtJohn Smithlt/namegt
  • ltnamegtCarol Smithlt/namegt
  • ltnamegtJim Sanderslt/namegt
  • lt/authorsgt

/
authors
name
name
name
name
John Smith
Joe Smith
Carol Smith
Jim Sanders
173
Example (XML to HTML)XSLT
  • ...
  • ltxsltemplate match"/"gt
  • ltxslapply-templates /gt
  • lt/xsltemplategt
  • ltxsltemplate match"authors"gt
  • lthtmlgt
  • ltxslapply-templates/gt
  • lt/htmlgt
  • lt/xsltemplategt
  • ltxsltemplate match"name"gt
  • ltPgtltBgtltFONT COLOR"RED"gt
  • ltxslvalue-of select"."/gt
  • lt/FONTgtlt/Bgtlt/Pgt
  • lt/xsltemplategt
  • ...

stylesheet
/
authors
name
apply-templates
html
P
apply-templates
B
FONT
color"RED"
value-of
174
Example (XML to HTML)Result Document
Result Tree
html
  • Resultant HTML file
  • lthtmlgt
  • ltPgtltBgtltFONT COLOR"red"gt
  • Joe Smith
  • lt/FONTgtlt/Bgtlt/Pgt
  • ltPgtltBgtltFONT COLOR"red"gt
  • Jim Sanders
  • lt/FONTgtlt/Bgtlt/Pgt
  • lt/htmlgt

..
P
P
B
B
FONT
FONT
Joe Smith
Jim Sanders
175
Example (XML to HTML)Result Viewed in IE5
176
XSLT Instructions
  • More instructions for XSLT including those for
  • conditional processing and sorting.

177
Summary Slide
  • Basic program logic
  • value-of, for-each and sort
  • Conditional processing
  • if and choose
  • Additional instructions
  • attribute, call-template, param and variable

178
XSLT Components
XML declaration
XSL lt?xml version"1.0" ?gt ltxslstylesheet
version"1.0" xmlnsxsl"http//www.w3.org/1999/
XSL/Transform"gt ltxsltemplate match"/"gt
ltxgt ltxslvalue-of select"a"/gt
lt/xgt lt/xsltemplategt lt/xslstylesheetgt
stylesheet
namespace
template rule
xslt 'instruction'
'literal' result element
"/" and "a" are XPath expressions
179
xslvalue-of
  • Extracts data/content from elements or attributes
    of the source document

Source Document lta x"hello"gt
ltbgtgoodbyelt/bgt lt/agt
XSLT ltxsltemplate match"a"gt ltpgtltxslvalue-of
select_at_x /gtlt/pgt ltpgtltxslvalue-of select"b"
/gtlt/pgt lt/xsltemplategt
Result ltpgthellolt/pgt ltpgtgoodbyelt/pgt
180
xslfor- each
Input ltbook isbn"14536"gt lttitlegtMonsterlt/tit
legt ltauthorgtMercer Mayerlt/authorgt
lttitlegtGo,Dog,Golt/titlegt ltauthorgtDr.
Seusslt/authorgt lt/bookgt
  • Selects zero or more
  • nodes for processing

XSLT ltxsltemplate match"book"gt ltpgt
ltxslfor-each select"title" gt
ltbgtltxslvalue-of select"."/gtlt/bgt
lt/xslfor-eachgt lt/pgt lt/xsltemplategt
Result ltpgt ltbgtOur Houselt/bgt
ltbgtGo,Dog,Golt/bgt lt/pgt
181
xslsort
Input ltbookgt lttitle isbn"5"gtMonsterlt/titlegt
ltauthorgtMercer Mayerlt/authorgt lttitle
isbn"2"gtGo,Dog,Golt/titlegt ltauthorgtDr.
Seusslt/authorgt lt/bookgt
  • Sorting order of node processing

XSLT ltxsltemplate match"book"gt ltpgt
ltxslfor-each select"title" gt ltxslsort
select"_at_isbn"/gt ltbgtltxslvalue-of
select"."/gtlt/bgt lt/xslfor-eachgt
lt/pgt lt/xsltemplategt
Result Tree ltpgt ltbgtGo,Dog,Golt/bgt
ltbgtMonsterlt/bgt lt/pgt
182
xslif
Input ltbookgt lttitle isbn"5" qty"60"gtOur
Houselt/titlegt ltauthorgtEd Poollt/authorgt lttitle
isbn"2" qty"49"gtGo,Dog,Golt/titlegt ltauthorgtDr.
Seusslt/authorgt lt/bookgt
XSLT ltxsltemplate match"book"gt ltpgt
ltxslfor-each select"title" gt ltxslif
test"_at_isbn2" gt ltbgtltxslvalue-of
select"."/gtlt/bgt lt/xslifgt lt/xslfor-eachgt
lt/pgt lt/xsltemplategt
Result ltpgt ltbgtGo,Dog,Golt/bgt lt/pgt
183
xslchoose
  • Case Processing with xslchoose, xslwhen,
    xslotherwise

Input ltbookgt lttitle isbn"5" qty"60"gtOur
Houselt/titlegt ltauthorgtEd Poollt/authorgt
lttitle isbn"2" qty"49"gtGo,Dog,Golt/titlegt
ltauthorgtDr. Seusslt/authorgt lttitle isbn"3"
qty"110"gtThe XSLT Gamelt/titlegt ltauthorgtJohn
Evdemonlt/authorgt lt/bookgt
184
xslchoose cont'd
Result ltpgt ltmediumgtOur Houselt/mediumgt
ltlowgtGo,Dog,Golt/lowgt lthighgtThe XSLT
Gamelt/highgt lt/pgt
XSLT ltxsltemplate match"book"gt
ltpgtltxslfor-each select"title" gt ltxslchoosegt
ltxslwhen test"_at_qty gt 100" gt
lthighgtltxslvalue-of select"."/gtlt/highgt
lt/xslwhengt
ltxslwhen test"(_at_qty gt 50) and (_at_qty
lt 100)"gt ltmediumgtltxslvalue-of
select"."/gtlt/mediumgt lt/xslwhengt
ltxslotherwisegt ltlowgtltxslvalue-of
select"."/gtlt/lowgt lt/xslotherwisegt
lt/xslchoosegt lt/xslfor-eachgtlt/pgt lt/xsltem
plategt
185
xslattribute
Input lt?xml version"1.0" ?gt ltlinkgt
http//www.abc.com lt/linkgt
XSLT ltxsltemplate match"link"gt ltAgt
ltxslattribute name"href"gt ltxslvalue-of
select"."/gt lt/xslattributegt ltxslvalue-of
select "." /gt lt/Agt lt/xsltemplategt
Output ltA href"http//www.abc.com"gt
http//www.abc.com lt/Agt
186
xslcall-template and xslparam
  • XSLT
  • ltxsltemplate match"document"gt
  • ltxslcall-template name"myTemplate" gt
  • ltxslwith-param name"arg1" select"//topic"
    /gt
  • ltxslwith-param name"arg2" select"_at_abc"
    /gt
  • lt/xslcall-templategt
  • lt/xsltemplategt
  • ltxsltemplate name"myTemplate" gt
  • ltxslparam name"arg1" select"/.." /gtlt!-- null
    nodeset --gt
  • ltxslparam name"arg2" select"/.." /gt
  • use arg1, arg2 here
  • lt/xsltemplategt

187
xslvariable
  • A variable is write once, read many. That is,
    you can assign a variable a value only once, but
    then you can retrieve the value of the variable
    many times.
  • Variables can be global or local
  • A variable has a scope limited to the XSL element
    that it is defined in.

188
xslvariable
XSLT ltxsltemplate match"book"gt ltpgt
ltxslvariable name"var1" select"title"/gt
ltxslvalue-of select"var1"/gt
lt/pgt lt/xsltemplategt
Input ltbook isbn"14536"gt lttitlegtGo,Dog,Golt/t
itlegt lt/bookgt
Result ltpgt Go,Dog,Go lt/pgt
189
XPath Functions
  • Using functions with XSLT

190
Summary Slide
  • Overview of Functions
  • Node Set Functions
  • Data from Another XML File
  • String Functions
  • Number Functions
  • Extensions

191
Overview of Functions
  • Used inside XSLT elements such as xslvalue-of
    and xslif
  • Specifications
  • XPath - Core functions
  • XSLT - Additional transformation functions
  • Exist for many types of data
  • node set, string, number, boolean,
  • Extensions - adding functionality

192
Node Set Functions
  • ltxslvalue-of select"..."/gt

/
a
b
b
b
"z"
"y"
"x"
193
Data from Another XML Filedocument()
  • ltxslvariable name"doc2"
  • select"document('other.xml')" /gt
  • lt!-- select nodes from the main document input
    --gt
  • ltxslfor-each select"topic" gt
  • ltxslvalue-of select"." /gt
  • lt/xslfor-eachgt
  • lt!-- process nodes from another document --gt
  • ltxslfor-each select"doc2/topic" gt
  • ltxslvalue-of select"." /gt
  • lt/xslfor-eachgt

194
String Functions
  • concat('HE', 'L', 'LO')
  • HELLO string
  • contains('HELLO', 'LL')
  • true boolean
  • substring-before('HELLO','LL')
  • HE string

195
Number Functions
  • sum(Cost)
  • adds up all the values in the child elements
    called 'Cost'
  • floor(2.7) -- 2
  • ceiling(2.7) -- 3
  • round(2.7) -- 3

196
Extensions - Calling Java
  • ltlxsltcomponent prefix"counter"
  • functions"read"gt
  • ltlxsltscript lang"javaclass"
  • src"MyCounter"/gt
  • lt/lxsltcomponentgt
  • ltxsltemplate match"/"gt
  • ltHTMLgt
  • ltxslvalue-of select"counterread('index')"/gt
  • lt/xsltemplategt

197
XSL
  • What is XSL? How does it relate to XSLT?
    Formatting Objects

198
Summary Slide
  • XSLT Transformation
  • XSL Layout
  • XSL Formatting Objects
  • XSL block Object
  • Sample PDF Output

199
XSLT Transformation
XML
transformation
formatting
html printer PDF
XML parser
Formatter
XSLT Engine
XSLT
XSL
  • Transformation and Formatting in separate steps
  • XSL is the intermediate vocabulary in a 2 stage
    process

200
XSL Layout
left-side
right-side
Page
  • XSL contains blocks, areas, margins, fonts, etc

201
XSL Formatting Objects
  • ltfopage-sequencegt
  • ltfoblockgt
  • ltxslapply-templates/gt
  • lt/foblockgt
  • ltfoblockgt
  • ltxslapply-templates/gt
  • lt/foblockgt
  • lt/fopage-sequencegt

202
XSL block Object
output file a.fo
  • ltfoblock font-size"18pt"
Write a Comment
User Comments (0)
About PowerShow.com