290 likes | 401 Views
Welcome. These presentation slides will be available on the NYS Forum Web site at www.nysforum.org http://www.nysforum.org/committees/webmastersguild/resources.aspx. Agenda. Opening Remarks (5 mins) OCIO/OFT Update (5 mins) XML Databases and XQuery (30 mins)
E N D
Welcome These presentation slides will be available on the NYS Forum Web site at www.nysforum.org http://www.nysforum.org/committees/webmastersguild/resources.aspx
Agenda Opening Remarks (5 mins) OCIO/OFT Update (5 mins) XML Databases and XQuery (30 mins) Brainstorming Planning Session (60 mins)
XML Databases and XQuery A Brief Introduction Jim Costello
XML - encoding documents electronically XSL - transforming and rendering XML documents XPath - addressing the parts of an XML document XML Database – storing collections of XML data XQuery - querying collections of XML data SQL/XML - querying XML within SQL XForms - interfacing with XML data XRX - XForms-REST-XML Database (All XML) Components of XML
Data exchange - XML enables platform-independent data exchange among applications. Web content management - usually implemented as a Web application, for creating and managing HTML content. Content is frequently, but not universally, stored as XML. RSS - a simple XML format used to syndicate headlines. Common Uses of XML
Relational no hierarchy or significant order; based on two-dimensional tables. Used for storing and querying data. Data is stored in columns and rows with key fields that join data together from separate tables; schema necessary. Data and Databases Relational vs. XML • XML • hierarchical and sequential; • based on trees in which order matters. • Used for exchanging and displaying data. • Data is stored as XML documents; can be highly structured, semi-structured, or unstructured; • schema not necessary.
Relational Database (tables, columns, rows, keys)
XML Database (collections, files)
From Web Form to Relational Database “shredding”
From Web Form to XML Database “as is”
"XML is by definition self-describing data. Build the database around that structure not the other way around. The implementation is far from being that simplistic. This basic concept however – leverage XML’s self-describing and hierarchical nature to manage it – is the very foundation of an XML database." (from http://bigmenoncontent.com/2009/05/28/xdb-matters/ ) The Real Difference
Got XML? (If you have more than a handful of XML documents to store, consider using an XML database.) Storing and querying document-centric XML, integrating data, and storing and querying semi-structured data. Handling rapidly evolving schemas, working with very large documents, querying hierarchical data, and running Web sites (content management). When and Why to Use an XML Database
By storing XML data as XML in XML database: Two Immediate Benefits • Simplified storage • New query capabilities
FLWOR Syntax: For – iterates through an input sequence Let – declares a variable and gives it a value Where – filters the selection Order by – sorts Return – defines the result Somewhat similar to Select statement in SQL: SELECT * FROM locationsTable WHERE city = “Albany” ORDER BY zip; XQuery
Perform query to select all registrations for a specific course and sort them by date Retrieving Data from Database • <class> • <className>Using XML for Web Site Management</className> • <location>Main Office</location> • <date>2010-01-21</date> • <timeStart>08:30:00</timeStart> • <timeEnd>12:30:00</timeEnd> • <firstName>James</firstName> • <lastName>Costello</lastName> • <organization>CTG</organization> • <phone>765-4321</phone> • <email>jjj@jj.com</email> • </class> • <class> • <className>Using XML for Web Site Management</className> • <location>Microknowledge</location> • <date>2010-06-04</date> • <timeStart>08:30:00</timeStart> • <timeEnd>16:30:00</timeEnd> • <firstName>Liz</firstName> • <lastName>Weaver</lastName> • <organization>Advocates for Homeless</organization> • <phone>518-777-1234</phone> • <email>liz.weaver@afh.org</email> • </class> • <class> • <className>Using XML for Web Site Management</className> • <location>Microknowledge</location> • <date>2010-06-04</date> • <timeStart>08:30:00</timeStart> • <timeEnd>16:30:00</timeEnd> • <firstName>Franklin</firstName> • <lastName>Parker</lastName> • <organization>Advocates for Homeless</organization> • <phone>518-777-4321</phone> • <email>franklin.parker@afg.org</email> • </class> • <class> • <className>Using XML for Web Site Management</className> • <location>00034</location> • <date>2010-08-11</date> • <timeStart>08:30:00</timeStart> • <timeEnd>12:30:00</timeEnd> • <firstName>James</firstName> • <lastName>Costello</lastName> • <organization>CTG</organization> • <phone>765-4321</phone> • <email>jjj@jj.com</email> • </class>
xquery version "1.0"; for $registrations in collection("classRegistrations")/classRegistrations/class let $date := $registrations/date/text() where $registrations/className = "Using XML for Web Site Management" order by $date return $registrations Simple FLWOR Statement
SELECT course.courseName, class.location, class.date, class.timeStart, class.timeEnd, student.firstName, student.lastName, student.organization, student.phone, student.email FROM course,class,student,classStudent WHERE course.courseName="Using XML for Web Site Management" and course.courseID = class.courseID and classStudent.classID = class.classID and classStudent.studentID = student.studentID ORDERBY class.date; Similar Statement in SQL
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="classRegistrations"> <xsl:for-each select="class"> <xsl:sort select="date"/> <xsl:variable name="cName"><xsl:value-of select="className"/></xsl:variable> <xsl:if test="$cName='Using XML for Web Site Management'"> <class> <className><xsl:value-of select="className"/></className> <location><xsl:value-of select="location"/></location> <date><xsl:value-of select="date"/></date> <timeStart><xsl:value-of select="timeStart"/></timeStart> <timeEnd><xsl:value-of select="timeEnd"/></timeEnd> <firstName><xsl:value-of select="firstName"/></firstName> <lastName><xsl:value-of select="lastName"/></lastName> <organization><xsl:value-of select="organization"/></organization> <phone><xsl:value-of select="phone"/></phone> <email><xsl:value-of select="email"/></email> </class> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> Similar Statement in XSL/XPath
New Query Capability Query Create a personalized RSS feed based on keyword(s) that an individual wants to track within CTG’s Website. How? Since all content on website is stored in XML database, it is all available to query. An XForms interface would enable visitors to submit their own terms of interest for building a personalized RSS.
New Query Results http://www.ctg.albany.edu/about/fulltextsearchRSS?param1=collaboration
New Query Capability Query Create a list of CTG publications grouped by main author. How? Since all content on website is stored in XML database, individual documents can be queried at the node level and combined, grouped and sorted into results that are difficult if not impossible to achieve without XQuery.
New Query Results http://www.ctg.albany.edu/publications/authorsList?sub=working
XML Databases - The Business Case http://www.cfoster.net/articles/xmldb-business-case/ Introduction to Native XML Databaseshttp://www.xml.com/pub/a/2001/10/31/nativexmldb.html Ronald Bourret, Consulting, writing, and research in XML and databaseshttp://www.rpbourret.com/xml/ Going Native: Making the Case for XML Databaseshttp://www.xml.com/pub/a/2005/03/30/native.html A comparison of XML-enabled and native XML data management techniqueshttp://xml.sys-con.com/node/104980?page=0,0 Feature Comparison: EMC Documentum xDB vs. Oracle XML DB & IBM DB2 pureXML https://community.emc.com/docs/DOC-2999 XRX: Simple, Elegant, Disruptivehttp://www.oreillynet.com/xml/blog/2008/05/xrx_a_simple_elegant_disruptiv_1.html Articles
Michael Kay’s XQuery Tutorials on Stylus Studio site http://www.stylusstudio.com/xquery_primer.html XQuery Wikibookhttp://en.wikibooks.org/wiki/XQuery XForms Wikibookhttp://en.wikibooks.org/wiki/XForms XRX Wikibookhttp://en.wikibooks.org/wiki/XRX w3Schools Tutorialhttp://www.w3schools.com/xquery/default.asp Various XQuery Linkshttp://delicious.com/jimcost/xquery Tutorials
eXist-db Open Source Native XML Database Gov 2.0 XQuery, XForms and RESTful Services XForms XML and Related Technologies Network XML Databases XML-in-Practice XQuery Network XRX Web Application Architecture Linkedin Groups
Jim CostelloCenter for Technology in Government jcostello@ctg.albany.edu twitter.com/jtcostello http://delicious.com/jimcost/xquery 518-442-3812 Contact
Open Forum Brainstorming Planning Session URL Shortener for NYS Mobile Apps Development group Link Management Approaches and software(Dreamweaver, Xenu, Siteimprove, Firefox Developer Kit) Credit Card Payment Processing Home-grown solutions? Outsourcing?Paypal?
Thank You See you next month Friday May 7, 2010 9:00 am to Noon NYS Museum Huxley Theatre Slides available at: http://www.nysforum.org/committees/webmastersguild/resources.aspx
SELECT course.courseName, class.location, class.date, class.timeStart, class.timeEnd, student.firstName, student.lastName, student.organization, student.phone, student.email FROM student INNER JOIN (course INNER JOIN (class INNER JOIN classStudent ON class.classID = classStudent.classID) ON (course.courseID = class.courseID) AND (course.ID = classStudent.ID)) ON (student.studentID = classStudent.studentID) AND (student.ID = class.ID) WHERE (((course.courseName)="Using XML for Web Site Management")) ORDER BY class.date; Similar Statement in SQL