DOM Interface subset 1/ 2

Similar documents
The attributes property of an element node returns a list of attribute nodes. It s called a named node map

Extensible Markup Language (XML) What is XML? Structure of an XML document. CSE 190 M (Web Programming), Spring 2007 University of Washington

INTERNET & WEB APPLICATION DEVELOPMENT SWE 444. Fall Semester (081) Module 4 (VII): XML DOM

Extensible Markup Language (XML) What is XML? An example XML file. CSE 190 M (Web Programming), Spring 2008 University of Washington

XML: Extensible Markup Language

Application Note AN Copyright InduSoft Systems LLC 2006

The Document Object Model (DOM) is a W3C standard. It defines a standard for accessing documents like HTML and XML.

SYBEX Web Appendix. DOM Appendix: The Document Object Model, Level 1

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1

XML: a "skeleton" for creating markup languages you already know it! <element attribute="value">content</element> languages written in XML specify:

XML CSC 443: Web Programming

CSI 3140 WWW Structures, Techniques and Standards. Representing Web Data: XML

Chapter 11 Objectives

Ingegneria del Software T. XML Programming

Jeff Offutt. SWE 642 Software Engineering for the World Wide Web

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9

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

Semi-structured Data. 8 - XPath

XML: Tools and Extensions

INDEX SYMBOLS See also

XML: Tools and Extensions

HTML vs. XML In the case of HTML, browsers have been taught how to ignore invalid HTML such as the <mymadeuptag> element and generally do their best

Ajax. Ronald J. Glotzbach

Document Object Model (DOM) A brief introduction. Overview of DOM. .. DATA 301 Introduction to Data Science Alexander Dekhtyar..

CSE 154 LECTURE 12: XML

Document Object Model (DOM)

Web Programming Step by Step

What is XML? XML is designed to transport and store data.

XML in the Development of Component Systems. The Document Object Model

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

XML Extensible Markup Language

[MS-DOM1X]: Microsoft XML Document Object Model (DOM) Level 1 Standards Support

One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while

AJAX: The Basics CISC 282 November 22, 2017

XML SCHEMA INFERENCE WITH XSLT

CSE 154 LECTURE 23: XML

AJAX: The Basics CISC 282 March 25, 2014

7.1 Introduction. extensible Markup Language Developed from SGML A meta-markup language Deficiencies of HTML and SGML

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views

XML Data Management. 5. Extracting Data from XML: XPath

Index. Rawlins_index.qxd 7/8/03 3:51 PM Page 587

~ Ian Hunneybell: DIA Revision Notes ~

XPath. Asst. Prof. Dr. Kanda Runapongsa Saikaew Dept. of Computer Engineering Khon Kaen University

XML Basics for Web Services

XML. XML Namespaces, XML Schema, XSLT

Part IV. DOM Document Object Model

Querying XML Data. Querying XML has two components. Selecting data. Construct output, or transform data

CSC Web Technologies, Spring Web Data Exchange Formats

7.1 Introduction. 7.1 Introduction (continued) - Problem with using SGML: - SGML is a meta-markup language

UNIT 3 XML DATABASES

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 7 XML

XML Schema for Job Definition Format. Graham Mann Internet Printing Group, Adobe Systems Inc

Chapter 13 XML: Extensible Markup Language

INLEDANDE WEBBPROGRAMMERING MED JAVASCRIPT INTRODUCTION TO WEB PROGRAMING USING JAVASCRIPT

XML. Semi-structured data (SSD) SSD Graphs. SSD Examples. Schemas for SSD. More flexible data model than the relational model.

Course: The XPath Language

The DOM approach has some obvious advantages:

Part IV. DOM Document Object Model. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 70

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

Web Services Resource Metadata 1.0 (WS-ResourceMetadataDescriptor)

Appendix H XML Quick Reference

Copyright Active Endpoints, Inc. All Rights Reserved 1

[MS-DOM1]: Internet Explorer Document Object Model (DOM) Level 1 Standards Support Document

XML. Objectives. Duration. Audience. Pre-Requisites

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

XPath Lecture 34. Robb T. Koether. Hampden-Sydney College. Wed, Apr 11, 2012

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

Index. Symbols "" (double quotes) handling in XML, 76

XML: Introduction. !important Declaration... 9:11 #FIXED... 7:5 #IMPLIED... 7:5 #REQUIRED... Directive... 9:11

Chapter 1: Getting Started. You will learn:

HR-XML Schema Extension Recommendation, 2003 February 26

[MS-DOM3C]: Internet Explorer Document Object Model (DOM) Level 3 Core Standards Support Document

XEP-0104: HTTP Scheme for URL Data

XML Standards for Ontology Exchange

XML. COSC Dr. Ramon Lawrence. An attribute is a name-value pair declared inside an element. Comments. Page 3. COSC Dr.

웹기술및응용. XML Schema 2018 년 2 학기. Instructor: Prof. Young-guk Ha Dept. of Computer Science & Engineering

XML Schema Element and Attribute Reference

XML extensible Markup Language

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

XML & Databases. Tutorial. 3. XPath Queries. Universität Konstanz. Database & Information Systems Group Prof. Marc H. Scholl

Informatics 1: Data & Analysis

EMERGING TECHNOLOGIES. XML Documents and Schemas for XML documents

XML Data Management. 6. XPath 1.0 Principles. Werner Nutt

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

Course: The XPath Language

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

Financial IT Examination Syllabus(2018)

Introduction. " Documents have tags giving extra information about sections of the document

Introduction. " Documents have tags giving extra information about sections of the document

COMP9321 Web Application Engineering. Extensible Markup Language (XML)

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

(One) Layer Model of the Semantic Web. Semantic Web - XML XML. Extensible Markup Language. Prof. Dr. Steffen Staab Dipl.-Inf. Med.

Financial IT Examination Syllabus(2017)

Navigating Input Documents Using Paths4

Altova XMLSpy 2007 Tutorial

INDEX. Symbols. Eloquent JavaScript 2011 by Marijn Haverbeke

Altova XMLSpy 2013 Tutorial

Part 2: XML and Data Management Chapter 6: Overview of XML

Introducing the JavaScript DOM

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

Transcription:

DOM Interface subset 1/ 2 Document attributes documentelement methods createelement, createtextnode, Node attributes nodename, nodevalue, nodetype, parentnode, childnodes, firstchild, lastchild, previoussibling, nextsibling, attributes methods insertbefore, replacechild, appendchild, haschildnodes DOM Interface subset 2/ 2 Element methods getattribute, setattribute, getelementsbytagname NodeList attributes length methods item CharacterData attributes data 1

Schema structure Elements are defined by <element name= type= minoccurs= maxoccurs= > name refers to the tag. type can be custom-defined or one of the standard types. Common predefined types include string, integer and anyuri. minoccurs and maxoccurs specify how many occurrences of the element may appear in an XML document. unbounded is used to specify no upper limits. Example <element name= title type= string minoccurs= 1 maxoccurs= 1 /> Sequences Sequences of elements are defined using a complextype container. <complextype> <sequence> <element name= title type= string /> <element name= author type= string maxoccurs= unbounded /> </sequence> Note: Defaults for both minoccurs and maxoccurs are 1 2

Nested Elements Instead of specifying an atomic type for an element as an attribute, its type can be elaborated as a structure. This is used to correspond to nested elements in XML. <element name= uct > <complextype> <sequence> </sequence> </element> <element name= title type= string /> <element name= author type= string maxoccurs= unbounded /> Extensions Extensions are used to place additional restrictions on the content of an element. Content must be a value from a given set: <element name= version > <simpletype> <restriction base= string > <enumeration value= 1.0 /> <enumeration value= 2.0 /> </restriction> </simpletype> </element> Content must conform to a regular expression: <element name= version > <simpletype> <restriction base= string > <pattern value= [1-9]\.[0-9]+ /> </restriction> </simpletype> </element> 3

Attributes Attributes can be defined as part of complextype declarations. <element name= author > <complextype> <simplecontent> <extension base= string > <attribute name= email type= string <attribute name= office type= integer <attribute name= type type= string /> </extension> </simplecontent> </element> Named Types Types can be named and referred to by name at the top level of the XSD. <element name= author type= uct:authortype /> <complextype name= authortype > <simplecontent> <extension base= string > <attribute name= email type= string <attribute name= office type= integer <attribute name= type type= string /> </extension> </simplecontent> 4

Other Content Models Instead of sequence, choice means that only one of the children may appear. all means that each child may appear or not, but at most once each. Many more details about content models can be found in specification! Schema Namespaces Every schema should define a namespace for its elements, and for internal references to types <schema xmlns= http://www.w3.org/2001/xmlschema targetnamespace= http://www.uct.ac.za xmlns:uct= http://www.uct.ac.za > <element name= author type= uct:authortype /> <complextype name= authortype > <simplecontent> <extension base= string > <attribute name= email type= string <attribute name= office type= number <attribute name= type type= string /> </extension> </simplecontent> </schema> 5

XPath XML Path Language (XPath) is a language to address particular nodes or sets of nodes of an XML document. Using XPath expressions we can write precise expressions to select nodes without procedural DOM statements. Examples: uct/title uct/version/number uct/author/@office XPath Syntax Expressions are separated by /. In general, each subexpression matches one or more nodes in the DOM tree. Each sub-expression has the form: axis::node[condition1][condition2] where axis can be used to select children, parents, descendents, siblings, etc. Shorthand notation uses symbols for the possible axes. 6

XPath Shorthand Expression What it selects in current context title title children * All children @office office attribute author[1] /uct/title[last()] //author... First author node Last title within uct node at top level of document All author nodes that are descendent from top level Context node Parent node version[number] Version nodes that have number children version[number= 1.0 ] Version nodes for which number has content of 1.0 XSLT Language 1/ 3 value-of is replaced with the textual content of the nodes identified by the XPath expression. <value-of select= uct:title /> text is replaced by the textual content. Usually the plain text is sufficient. <text>1.0</text> 1.0 element is replaced by an XML element with the indicated tag. Usually the actual tag can be used. <element name= dc:publisher >UCT</element> <dc:publisher>uct</dc:publisher> 7

XSLT Language 2/3 apply-templates explicitly applies templates to the specified nodes. <apply-templates select= uct:version /> call-template calls a template like a function. This template may have parameters and must have a name attribute instead of a match. <call-template name= doheader > <with-param name= lines >5</with-param> </call-template> <template name= doheader > <param name= lines >2</param> </template> XSLT Language 3/3 variable sets a local variable. In XPath expressions, a $ prefix indicates a variable or parameter instead of a node. <variable name= institution >UCT</variable> <value-of select= $institution /> <place institution= {$institution} /> Selection and iteration examples: <if test= position()=last() > </if> <choose> <when test= $val=1 > </when> <otherwise> </otherwise> </choose> <for-each select= uct:number > </for-each> 8