1 / 15

EXTENSIBLE MARKUP LANGUAGE ( XML )

EXTENSIBLE MARKUP LANGUAGE ( XML ). Kristina Coha Damir Jurić Marija LJubešić. Definicija XML-a. to je metajezik ... jezik za opisivanje drugih jezika , koji vam omogucuje da napravite vlastiti markup ili tag.

rusk
Download Presentation

EXTENSIBLE MARKUP LANGUAGE ( XML )

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EXTENSIBLE MARKUP LANGUAGE ( XML ) Kristina Coha Damir Jurić Marija LJubešić

  2. Definicija XML-a • to je metajezik ... jezik za opisivanje drugih jezika , koji vam omogucuje da napravite vlastiti markup ili tag. • XML je jezik napisan u SGML-u , internacionalnom standardnom jeziku za tekstovne markup sisteme.

  3. Svojstva XML-a • nema fiksno definirane tagove • nema semantike • XML procesor ne zna što XML datoteka znači • XML markup ne sadrži informacije o formatiranju • sadržaj je odvojen od prikaza

  4. Pisanje XML datoteka • svaka XML datoteka mora biti well-formed , što znači da: • vrijednosti atributa - zatvorene jednostrukim ili dvostrukim navodnicima • početni i krajnji tag • prazni elementi - (/) na kraju početnog taga • elementi - pravilno ugniježđeni

  5. Transformiranje XML datoteka • Document Type Definition ( DTD ) - valid XML • XML Schema (XML Data Reduced -XDR) • Cascade Stylesheets ( CSS ) • Extensible Stylesheets ( XSL ) • XML API ( SAX,DOM,...) za neki od XML parsera ( MSXML, Xerces, ProjectX,...)

  6. Općenito o XSL-u • XSL specificira prezentaciju XML informacija koristeci dvije osnovne tehnike: -transformiranje u HTML-opisivanje kako da se prezentira transformirana informacija

  7. XSL se satoji od tri jezika: • XPath ( XPointer i XLink ) definira XML dijelove i uzorke • XSL Transformations ( XSLT ) transformira XML • XSL Formatting Objects formatira XML

  8. Primjer za XPath <contact category="enemy of the state"> <fullname>Smith</fullname> <numbers> <home>801-555-2323</home> <cell>801-555-3232</cell> </numbers> </contact> ---------------------------------------------------------------------------/descendant::contact[fullname="Smith"]/child::numbers/child::*

  9. Struktura jednostavnog XSLT stylesheet-a <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="<XPATH EXPRESSION>"> <!— transformation defined here —> </xsl:template> </xsl:stylesheet>

  10. Povezivanje XML-a i XSL-a • dodavanjem reference u XML dokument na XSL dokument • korištenjem JavaScript u klijentovom browseru • transformiranjem na serveru korištenjem ASP i VBScript-a

  11. <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="cd_catalog.xsl"?> <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD> </CATALOG>

  12. <?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html> <body> <table border="2" bgcolor="yellow"> <tr> <th>Title</th> <th>Artist</th> </tr> <xsl:for-each select="CATALOG/CD" order-by="+ ARTIST"> <tr> <td><xsl:value-of select="TITLE"/></td> <td><xsl:value-of select="ARTIST"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>

  13. <html> <body> <script language="javascript"> // Load XML var xml = new ActiveXObject("Microsoft.XMLDOM") xml.async = false xml.load("cd_catalog.xml") // Load the XSL var xsl = new ActiveXObject("Microsoft.XMLDOM") xsl.async = false xsl.load("cd_catalog.xsl") // Transform document.write(xml.transformNode(xsl)) </script> </body> </html>

  14. <% 'Load the XML set xml = Server.CreateObject("Microsoft.XMLDOM") xml.async = false xml.load(Server.MapPath("cd_catalog.xml")) 'Load the XSL set xsl = Server.CreateObject("Microsoft.XMLDOM") xsl.async = false xsl.load(Server.MapPath("cd_catalog.xsl")) 'Transform the file Response.Write(xml.transformNode(xsl)) %>

More Related