Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Information Systems Information Systems California State University Los Angeles Jongwook Woo CIS 561 Design of an E-Commerce Site XML Validation.

Similar presentations


Presentation on theme: "Computer Information Systems Information Systems California State University Los Angeles Jongwook Woo CIS 561 Design of an E-Commerce Site XML Validation."— Presentation transcript:

1 Computer Information Systems Information Systems California State University Los Angeles Jongwook Woo CIS 561 Design of an E-Commerce Site XML Validation Jongwook Woo, PhD jwoo5@calstatela.edu California State University, Los Angeles Computer Information Systems Department

2 CSLA Computer Information Systems Information Systems Jongwook Woo 2 XML Validation nXML Validation nXML Validator nXML Browsers nXML Viewing nXML Data Island nXML Parser

3 CSLA Computer Information Systems Information Systems Jongwook Woo 3 Well Formed XML Documents nA "Well Formed" XML document has correct XML syntax. mA "Well Formed" XML document is a document that conforms to the XML syntax rules that were described in the previous chapters: –XML documents must have a root element –XML elements must have a closing tag –XML tags are case sensitive –XML elements must be properly nested –XML attribute values must always be quoted

4 CSLA Computer Information Systems Information Systems Jongwook Woo 4 Valid XML Documents nA "Valid" XML document is a "Well Formed" XML document, mAnd, which also conforms to the rules of a Document Type Definition (DTD) or Schema: nXML DTD mA DTD defines the legal elements of an XML document. mThe purpose of a DTD is to define the legal building blocks of an XML document. nXML Schema mXML Schema is an XML based alternative to DTD. mW3C supports an alternative to DTD called XML Schema.

5 CSLA Computer Information Systems Information Systems Jongwook Woo 5 XML Validator nErrors in XML documents will stop your XML program. mThe W3C XML specification states that a program should not continue to process an XML document if it finds an error. nWith HTML, possible to create documents with lots of errors mlike when you forget an end tag mOne of the main reasons that HTML browsers are so big and incompatible, – they have their own ways to figure out what a document should look like when they encounter an HTML error. mWith XML this should not be possible –All XML S/Ws are compatible nXML Validator mhttp://www.w3schools.com/xml/xml_validator.asp

6 CSLA Computer Information Systems Information Systems Jongwook Woo 6 XML Browser Support nNearly all major browsers have support for XML and XSLT. nMozilla Firefox mSince version 1.0.2, Firefox has support for XML and XSLT (and CSS) nInternet Explorer mSince version 6, Internet Explorer supports XML, Namespaces, CSS, XSLT, and XPath. mNote: Internet Explorer 5 also has XML support, but the XSL part is NOT compatible with the official W3C XSL Recommendation!

7 CSLA Computer Information Systems Information Systems Jongwook Woo 7 XML Browser Support (Cont’d) nOpera mSince version 9, Opera has support for XML and XSLT (and CSS). Version 8 supports only XML + CSS. nMozilla mMozilla includes Expat for XML parsing and has support to display XML + CSS. Mozilla also has some support for Namespaces. mMozilla is available with an XSLT implementation. nNetscape mSince version 8, Netscape uses the Mozilla engine, and therefore it has the same XML / XSLT support as Mozilla.

8 CSLA Computer Information Systems Information Systems Jongwook Woo 8 XML Viewing http://www.w3schools.com/xml/xml_view.asp nLook at this XML file: note.xmlnote.xml mNote: Do not expect XML files to be formatted like HTML documents! nViewing an Invalid XML File mIf an erroneous XML file is opened, the browser will report the error. mLook at this XML file: note_error.xmlnote_error.xml nOther XML Examples mAn XML CD catalog This is the author’s father's CD collection, stored as XML dataAn XML CD catalog mAn XML plant catalog This is a plant catalog from a plant shop, stored as XML data.An XML plant catalog mA Simple Food Menu This is a breakfast food menu from a restaurant, stored as XML data.A Simple Food Menu

9 CSLA Computer Information Systems Information Systems Jongwook Woo 9 XML Viewing http://www.w3schools.com/xml/xml_view.asp (Cont’d) nWhy Does XML Display Like This? mXML documents do not carry information about how to display the data. mSince XML tags are "invented" by the author of the XML document, –browsers do not know if a tag like describes an HTML table or a dining table. nWithout any information about how to display the data, mmost browsers will just display the XML document as it is.

10 CSLA Computer Information Systems Information Systems Jongwook Woo 10 XML Displaying nWith CSS (Cascading Style Sheets) madd display information to an XML document. mhttp://www.w3schools.com/xml/xml_display.asphttp://www.w3schools.com/xml/xml_display.asp –http://www.w3schools.com/xml/cd_catalog_with_css.xmlhttp://www.w3schools.com/xml/cd_catalog_with_css.xml nDisplaying XML with XSL (the eXtensible Stylesheet Language) mXSL is the preferred style sheet language of XML. mfar more sophisticated than CSS. – to transform XML into HTML before it is displayed by the browser –http://www.w3schools.com/xml/xml_xsl.asphttp://www.w3schools.com/xml/xml_xsl.asp View the XML file, the XSL style sheet, and View the result.View the XML filethe XSL style sheetView the result

11 CSLA Computer Information Systems Information Systems Jongwook Woo 11 XML Displaying (Cont’d) nBelow is a fraction of the XML file. mThe second line,, links the XML file to the XSL file: Belgian Waffles $5.95 two of our famous Belgian Waffles 650

12 CSLA Computer Information Systems Information Systems Jongwook Woo 12 XML Data Island nXML data embedded into an HTML page mNote: only for Internet Explorer mXML document ("note.xml"): Tove Jani Reminder Don't forget me this weekend!

13 CSLA Computer Information Systems Information Systems Jongwook Woo 13 XML Data Island (Cont’d) nThen, in an HTML document, myou can embed the XML file previous with the tag. –The id attribute of the tag defines an ID for the data island, –and the src attribute points to the XML file to embed: mHowever, the embedded XML data is, up to this point, not visible for the user. –The next step is to format and display the data in the data island by binding it to HTML elements.

14 CSLA Computer Information Systems Information Systems Jongwook Woo 14 XML Data Island (Cont’d) nBind Data Island to HTML Elements membed an XML file called "cd_catalog.xml" into an HTML file. mView "cd_catalog.xml".View "cd_catalog.xml" –http://www.w3schools.com/xml/cd_catalog.xml mThe HTML file looks like this:

15 CSLA Computer Information Systems Information Systems Jongwook Woo 15 XML Data Island (Cont’d) nExample explained: mThe datasrc attribute of the tag –binds the HTML table element to the XML data island. –refers to the id attribute of the data island. m tags cannot be bound to data, so we are using tags. –The tag allows the datafld attribute to refer to the XML element to be displayed. –In this case, it is datafld="ARTIST" for the element and datafld="TITLE" for the element in the XML file. –As the XML is read, additional rows are created for each element. nIf you are running IE 5.0 or higher, try it mhttp://www.w3schools.com/xml/tryit.asp?filename=cd_catalog_island nAlso try this example, demonstrating,, and.this example mhttp://www.w3schools.com/xml/tryit.asp?filename=cd_catalog_island_thead

16 CSLA Computer Information Systems Information Systems Jongwook Woo 16 XML Parser nExample: News in XML for real life … … nS/W myou will need an XML parser, –To read and update - create and manipulate - an XML document, mMSXML Parser for IE mXML Parser for Mozilla


Download ppt "Computer Information Systems Information Systems California State University Los Angeles Jongwook Woo CIS 561 Design of an E-Commerce Site XML Validation."

Similar presentations


Ads by Google