XML processing in ColdFusion MX

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

XML Schema Heewon Lee. Contents 1. Introduction 2. Concepts 3. Example 4. Conclusion.
What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
XML: Extensible Markup Language
Leveraging XML with ColdFusion Jeff Tapper June 2004.
1 XML DTD & XML Schema Monica Farrow G30
Introduction XML Technologies Mark Graves. This presentation is Copyright 2001, 2002 by Mark Graves and contains material Copyright 2002 by Prentice Hall.
XML Parsing Using Java APIs AIP Independence project Fall 2010.
Java API for XML Processing (JAXP) CSE 4/586: Distributed Systems Department of Computer Science and Engineering University at Buffalo, New York Jia Zhao.
28-Jun-15 StAX Streaming API for XML. XML parser comparisons DOM is Memory intensive Read-write Typically used for documents smaller than 10 MB SAX is.
XML Introduction What is XML –XML is the eXtensible Markup Language –Became a W3C Recommendation in 1998 –Tag-based syntax, like HTML –You get to make.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Introduction to XML This material is based heavily on the tutorial by the same name at
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
Chapter 4 Web Pages Using Web Standards Chapter 3 XML – the ‘X’ in Ajax.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
XML processing in ColdFusion MX Everything you wanted to know about XML, but were afraid to ask October 2006 Jaxfusion User Group.
XSLT for Data Manipulation By: April Fleming. What We Will Cover The What, Why, When, and How of XSLT What tools you will need to get started A sample.
XML and its applications: 4. Processing XML using PHP.
Structured-Document Processing Languages Spring 2011 Course Review Repetitio mater studiorum est!
ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.
ASP.NET and XML Presented By: Shravan S. Mylavarapu 1.
School of Computing and Management Sciences © Sheffield Hallam University To understand the Oracle XML notes you need to have an understanding of all these.
XML eXtensible Markup Language w3c standard Why? Store and transport data Easy data exchange Create more languages WSDL (Web Service Description Language)
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
Session IV Chapter 9 – XML Schemas
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
Utilizing XML in ColdFusion MX by Attila Domokos.
Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham.
XML eXtensible Markup Language. XML A method of defining a format for exchanging documents and data. –Allows one to define a dialect of XML –A library.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Web Technologies Lecture 4 XML and XHTML. XML Extensible Markup Language Set of rules for encoding a document in a format readable – By humans, and –
QUALITY CONTROL WITH SCHEMAS CSC1310 Fall BASIS CONCEPTS SchemaSchema is a pass-or-fail test for document Schema is a minimum set of requirements.
What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized.
XML and Object Serialization. Structure of an XML Document Header Root Element Start Tags / End Tags Element Contents – Child Elements – Text – Both (mixed.
1 Introduction JAXP. Objectives  XML Parser  Parsing and Parsers  JAXP interfaces  Workshops 2.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Martin Kruliš by Martin Kruliš (v1.1)1.
Tutorial 9 Working with XHTML. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Describe the history and theory of XHTML.
CIS 228 The Internet 9/20/11 XHTML 1.0. “Quirks” Mode Today, all browsers support standards Compliant pages are displayed similarly There are multiple.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
CITA 330 Section 4 XML Schema. XML Schema (XSD) An alternative industry standard for defining XML dialects More expressive than DTD Using XML syntax Promoting.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
1 Introduction to XML Babak Esfandiari. 2 What is XML? introduced by W3C in 98 Stands for eXtensible Markup Language it is more general than HTML, but.
Coding With XML Andrew Schwabe
Extensible Markup Language (XML) Pat Morin COMP 2405.
Unit 4 Representing Web Data: XML
CIS 228 The Internet 9/20/11 XHTML 1.0.
Creating a Well-Formed Valid Document
Tutorial 9 Working with XHTML
Tutorial 9 Working with XHTML
ACG 4401 XML Schemas XML Namespaces XLink.
Java XML IS
Server-Side Application and Data Management IT IS 3105 (FALL 2009)
XML in Web Technologies
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Database Processing with XML
Chapter 7 Representing Web Data: XML
Chapter X IXXXXXXXXXXXXXXXX.
دانشكده مهندسي كامپيوتر
Tutorial 9 Working with XHTML
Python and XML Styling and other issues XML
XML and its applications: 4. Processing XML using PHP
CIT 383: Administrative Scripting
More XML XML schema, XPATH, XSLT
Quick Introduction to DFDL
XML: The new standard -Eric Taylor.
Presentation transcript:

XML processing in ColdFusion MX Everything you wanted to know about XML, but were afraid to ask October 2006 Jaxfusion User Group

About the Presenter David Fekke Working with XML 1999 Lead for Vurv HR-XML API

Covered in this presentation Properly formed XML ColdFusion XML Tags and functions XPath queries XML XSDs and Validation XML Namespaces DOM vs. Streaming parsers StAX API

XML eXtensible Markup Language Originated from SGML W3C standard More versatile then Flat files

XML Syntax XML declaration <?xml version="1.0" encoding="UTF-8"?> Must have one root tag <pre:roottag> </pre:roottag> All tags must have closing tag. <br />: single tags can have forward slash at the end <tag name=“value” /> tags can have attributes

Pre MX XML features WDDX SOXML custom tag, windows only

ColdFusion MX 6 CFXML tag turns serialized XML into a ColdFusion object XMLParse() function ColdFusion XML Object works like series of structures and arrays XMLSearch() function XMLSearch Uses XPath queries to return array of XML nodes

XML Check functions IsXML IsXmlDoc IsWDDX IsXmlAttribute IsXmlElem IsXmlNode IsXmlRoot

XML editing functions XmlNew() XmlChildPos() XmlTransform() XmlElemNew()

ColdFusion MX 7 Functions XmlGetNodeType() XmlValidate()

XPath queries Provides a way to pull the elements you need without having to iterate through the entire DOM /rootelement/parent/childelement //childelement /rootelement/parent[childelement = “foo”] Used with XSLT templates

XML Validation Define XML with DTD or XSD XSD preferred method for validation XSD uses an XML format Allows for strict and custom datatypes Allows for pattern recognition

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="FirstName" type="xs:string"/> <xs:element name="LastName" type="xs:string"/> <xs:element name="Age" type="xs:string"/> <xs:element name="customer"> <xs:complexType> <xs:sequence> <xs:element ref="FirstName" /> <xs:element ref="LastName" /> <xs:element ref="Age" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="customers"> <xs:element ref="customer" maxOccurs="unbounded" /> </xs:schema>

<?xml version="1.0" encoding="UTF-8" ?> <customers> <customer> <FirstName>Dwight</FirstName> <LastName>Mercer</LastName> <Age>32</Age> </customer> <FirstName>Miguel</FirstName> <LastName>Cabrera</LastName> <Age>33</Age> </customers>

Default XSD element types xs:String xs:normalizedString xs:integer xs:base64Binary xs:negativeInteger xs:positiveInteger xs:Hexbinary xs:Long xs:short

Custom Types <xsd:simpleType name="SKU"> <xsd:restriction base="xsd:string"> <xsd:pattern value="\d{3}-[A-Z]{2}"/> </xsd:restriction> </xsd:simpleType>

XML Namespaces Namespaces allow for XML to be segmented into different parts <namespace:elementName /> namespace will prefix the element name <fekke:root xmlns:fekke=“http://www.fekke... No namespace xmlns=“” Use explicit XPath with no namespace Nonamespace xpath=“/:element”

DOM, SAX and Pull Parsers ColdFusion uses a DOM parser. Entire XML object in memory. SAX parser reads in file portion of the time. Raises events when elements match. StAX uses pull based parser to read one node at time. Uses streams to read in portion

StAX BEA JSR 173 Many implementations Includes Event and Pull parsers Jim Collins working on CFStAX library Woodstox library extremely fast implementation

StAX objects XMLInputFactory XMLStreamConstants XMLStreamReader XMLEventReader

XMLStreamConstants Constants for different node types XMLStreamConstants.START_ELEMENT XMLStreamConstants.END_ELEMENT XMLStreamConstants.START_DOCUMENT XMLStreamConstants.END_DOCUMENT

XmlStreamReader methods Next() iterates through XML stream getLocalName() returns tag name getAttributeCount() returns tags attribute count getAttributeLocalName() returns attribute name getAttributeValue() returns attribute value hasText() returns boolean if element has text getText() returns element text

Free XML Tools IE and Firefox have built in DOM parsers XMLFox for testing validation XMLButterfly for editing and formatting XML Don’t use ALtova XML Spy, its crap!

Summary Use XMLSearch instead of iterating through DOM Don’t use cfsavecontent to build XML, use CFXML If using no namespace, use explicit xpaths Use xmlFormat or CDATA to handle special characters Use XSDs over DTDs

Links http://www.w3.org/XML/ http://www.w3.org/XML/Schema http://www.xml.com/ http://coldfusion.sys-con.com/read/236002.htm

Books ColdFusion Application Development Beginning XML (Programmer to Programmer) O’reilly XML in a Nutshell