Docsity

XML and XSLT: Sharing Database Data with Suppliers using XML, Study notes of Database Management Systems (DBMS)

Toggle sidebar
bg1
CSIS 350 โ€“ Lecture 27
Announcements
Exam Review next time. Come prepared to ask questions.
Discuss homework status.
Chapter 13
Let's say that you have a big organization, and you want to share DB data with your
suppliers to automate delivery of new products. So, transactions from your invoice DB
need to be sent to the various suppliers, and loaded as transactions in their DB.
How might you go about doing this? What should the extracted data look like?
XML
XML (extensible Markup Language)
- standard way to describe content of documents
- customizable
- can use it to describe a database view so that extracts are easily understood
Compare with HTML
- both markup languages
- HTML contains markup for content, structure, and materialization (how
document will appear)
- HTML has fixed set of tags, XML allows you to define new tags.
- HTML tags are confounded โ€“ what does <h2> tag mean?
oheading
obold, certain size font
Example XML document - See the file Figure13-1.xml
Note that this file has two parts:
- the top part is called the Document Type Declaration, or DTD
- the second part is the data
DTD:
- describes structure of document
- metadata!
DTD:
- begins with the word DOCTYPE โ€“ in this case the type is Customer
- Then it specifies the content of the document
pf3
pf4
pf5

Partial preview of the text

Download XML and XSLT: Sharing Database Data with Suppliers using XML and more Study notes Database Management Systems (DBMS) in PDF only on Docsity!

CSIS 350 โ€“ Lecture 27

Announcements Exam Review next time. Come prepared to ask questions. Discuss homework status. Chapter 13 Let's say that you have a big organization, and you want to share DB data with your suppliers to automate delivery of new products. So, transactions from your invoice DB need to be sent to the various suppliers, and loaded as transactions in their DB. How might you go about doing this? What should the extracted data look like? XML XML (extensible Markup Language)

  • standard way to describe content of documents
  • customizable
  • can use it to describe a database view so that extracts are easily understood Compare with HTML
  • both markup languages
  • HTML contains markup for content, structure, and materialization (how document will appear)
  • HTML has fixed set of tags, XML allows you to define new tags.
  • HTML tags are confounded โ€“ what does tag mean? o heading o bold, certain size font Example XML document - See the file Figure13-1.xml Note that this file has two parts:
  • the top part is called the Document Type Declaration, or DTD
  • the second part is the data DTD:
  • describes structure of document
  • metadata! DTD:
  • begins with the word DOCTYPE โ€“ in this case the type is Customer
  • Then it specifies the content of the document

In this example, the data conforms to the DTD โ€“ it is said to be type-valid. If the data did not conform to the DTD it would be type-invalid. It could still be an XML document: for example, if there were two s. More typically, the DTD is stored separately from the data. In this case, the !DOCTYPE definition includes a reference to the file that contains the DTD, like this:

See Example.xml and customerlist.dtd. The advantage of this is that lots of documents can use the same DTD. What happens if we try to look at the above document in a browser? Well, depending on the browser, different things will happen, but usually you'll see the structure of the document. XSLT HTML tags also describe how a document should be materialized or formatted. XML document does not include this. With XML, there is a separate part that does this: XSLT (Extensible Style Language: Transformations). XSLT is transformation language that can be used to convert an XML document into another form:

  • HTML
  • XML in a different format XSLT is a declarative, transformational language
  • uses rules (instead of a procedure)
  • transforms input document into an output document XSLT uses a stylesheet to define the rules. Let's look at an example that transforms a customerList XML file into some HTML: Look at customerlist.dtd, Example.XML, and CustomerList-StyleSheet.xsl. The XSLT processor copies the stylesheet until it finds a command (marked with "
  • artStyle is defined as an attribute instead of as an element.
  • the schema is referenced at the top of the document. Schemas can be flat or structured. A flat schema has all elements at the same level. Slide 3 โ€“ an example of a flat schema. Optional elements have minOccur = 0. Note that the elements have data types in this example. Slide 4 โ€“ an example XML document that is schema-valid. Slide 5 โ€“ a diagram showing the structure. Note that optional elements are shown dashed. In Slide 4, there is no country. If we think about this data carefully, we can see that we've left some of the semantics out. Things like street, city, zip make up an Address. Area code and phone number go together also. We'd like to capture this structure. Structured types have multiple levels that allow us to do this. Slide 6 โ€“ Example schema with PhoneType and AddressType Slide 7 โ€“ XML document that uses this schema Slide 8 โ€“ Graphical representation Doing this also allows us to avoid duplicate definitions โ€“ we can use these types in multiple locations. For example, a customer and a salesperson both have phone numbers. See slides 9, 10 and 11. OK, so we can see how to represent data in XML form. The schema tells us what the data looks like, the XML documents tell us what the data is, and we can use XSLT to transform XML documents from one form to another. So, how do we get data in/out of databases into XML? Well, this is pretty new stuff, but we can look at a bit of it with SQL Server. The select statement includes a FOR XML clause. Let's look at some examples: [See my other notes, use SQL Server] Other techniques: ADO.net (see slide 12) SQL/XML
  • allows you to store XML data directly in database, and validate it using CHECK constraints. Finally, lots of industries are using this. See slides 13 and 14.