1 / 9

Initiation à XML

Initiation à XML. Sebti Foufou. De HTML à XML (HTML). <HTML> <HEAD> <TITLE>Lime Jello Marshmallow Cottage Cheese Surprise</TITLE> </HEAD>

prema
Download Presentation

Initiation à 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. Initiation à XML Sebti Foufou

  2. De HTML à XML (HTML) <HTML> <HEAD><TITLE>Lime Jello Marshmallow Cottage Cheese Surprise</TITLE> </HEAD> <BODY><H3>Lime Jello Marshmallow Cottage Cheese Surprise</H3>My grandma's favorite (may she rest in peace).<H4>Ingredients</H4><TABLE BORDER="1"><TR BGCOLOR="#308030"><TH>Qty</TH><TH>Units</TH><TH>Item</TH></TR><TR><TD>1</TD><TD>box</TD><TD>lime gelatin</TD></TR><TR><TD>500</TD><TD>g</TD><TD>multicolored marshmallows</TD></TR><TR><TD>500</TD><TD>ml</TD><TD>cottage cheese</TD></TR><TR><TD></TD><TD>dash</TD><TD>Tabasco sauce (optional)</TD></TR></TABLE><P><H4>Instructions</H4><OL><LI>Prepare lime gelatin according to package instructions...</LI><!-- and so on --> </BODY> </HTML>

  3. De HTML à XML (Affichage html ie6) • Lime Jello Marshmallow Cottage Cheese Surprise • My grandma's favorite (may she rest in peace). • Ingredients • Instructions • Prepare lime gelatin according to package instructions... Qty Units Item 1 box lime gelatin 500 g multicolored tiny marshmallows 500 ml Cottage cheese dash Tabasco sauce (optional)

  4. De HTML à XML (XML) <?xml version="1.0"?> <Recipe>   <Name>Lime Jello Marshmallow Cottage Cheese Surprise</Name>  <Description> My grandma's favorite (may she rest in peace).   </Description> <Ingredients>      <Ingredient>  <Qty unit="box">1</Qty> <Item>lime gelatin</Item>  </Ingredient>      <Ingredient> <Qty unit="g">500</Qty> <Item>multicolored tiny marshmallows</Item> </Ingredient>      <Ingredient> <Qty unit="ml">500</Qty> <Item>Cottage cheese</Item> </Ingredient>      <Ingredient> <Qty unit="dash"/> <Item optional="1">Tabasco sauce</Item> </Ingredient> </Ingredients> <Instructions>  <Step> Prepare lime gelatin according to package instructions      </Step> <!-- And so on... -->   </Instructions> </Recipe>

  5. De HTML à XML (DTD) <!-- This is the example DTD for the example XML --> <!ELEMENT Recipe (Name, Description?, Ingredients?, Instructions?)> <!ELEMENT Name (#PCDATA)> <!ELEMENT Description (#PCDATA)> <!ELEMENT Ingredients (Ingredient)*> <!ELEMENT Ingredient (Qty, Item)> <!ELEMENT Qty (#PCDATA)> <!ATTLIST Qty unit CDATA #REQUIRED> <!ELEMENT Item (#PCDATA)> <!ATTLIST Item optional CDATA "0"  isVegetarian CDATA "true"> <!ELEMENT Instructions (Step)+>

  6. De HTML à XML (Affichage xml ie6)

  7. De HTML à XML (XSLT) <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/Recipe"><HTML><HEAD><TITLE><xsl:value-of select="Name"/></TITLE> </HEAD> <BODY> <H3> <xsl:value-of select="Name"/> </H3>     <STRONG> <xsl:value-of select="Description"/> </STRONG>     <xsl:apply-templates/>  </BODY> </HTML> </xsl:template> <!-- Format ingredients --> <xsl:template match="Ingredients">     <H4>Ingredients</H4> <TABLE BORDER="1">  <TR BGCOLOR="#308030"> <TH>Qty</TH><TH>Units</TH><TH>Item</TH></TR> <xsl:for-each select="Ingredient">     <TR>                 <!-- handle empty Qty elements separately --> <xsl:if test='Qty[not(.="")]' > <TD><xsl:value-of select="Qty"/></TD></xsl:if>          <xsl:if test='Qty[.=""]' > <TD BGCOLOR="#404040"></TD>  </xsl:if>          <TD><xsl:value-of select="Qty/@unit"/></TD>

  8. XSLT (suite) <TD><xsl:value-of select="Item"/> <xsl:if test='Item/@optional="1"'> <SPAN> -- <em><STRONG>optional</STRONG></em></SPAN> </xsl:if> </TD>        </TR>   </xsl:for-each>         </TABLE> </xsl:template>  <!-- Format instructions --> <xsl:template match="Instructions">        <H4>Instructions</H4>        <OL>        <xsl:apply-templates select="Step"/>  </OL> </xsl:template>  <!-- Format Step --> <xsl:template match="Step"> <LI><xsl:value-of select="."/></LI> </xsl:template>  <!-- ignore all not matched --> <xsl:template match="*" priority="-1"/>  </xsl:stylesheet>

  9. XML: Ce qu’il faut connaître • HMLT • Contenu : La description XML de W3C • Validité : Un moyen (langage) pour contrôler le contenu du document XML • DTD • XML Schemas de la W3C • Présentation : un moyen pour contrôler l’apparence du contenu du document XML dans le navigateur • Feuille de style CSS • Le langage de transformation XSLT

More Related