Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2008
    Posts
    136
    Thanks
    39
    Thanked 1 Time in 1 Post

    Showing XML Data

    Hi all,
    I have an XML file, an XML Schema file, and an XSL Transform file, and I would like to display the data from the XML data in an XHTML file. How would I go about achieving this?

    Thanks for any help

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,460
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Any source code you care to share? We need more to go on.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #3
    Regular Coder
    Join Date
    Mar 2008
    Posts
    136
    Thanks
    39
    Thanked 1 Time in 1 Post
    If you really need the code, here it is:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <?xml-stylesheet type="text/xsl" href="XSLT Revision.xslt"?>
    <games xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="XSD Revision.xsd">
      <game>
        <name>Team Fortress 2</name>
        <platform>PC</platform>
        <price>12.00</price>
        <developer>Valve</developer>
        <publisher>Valve</publisher>
      </game>
      <game>
        <name>Battlefield 1943</name>
        <platform>PC</platform>
        <price>15.00</price>
        <developer>EA Games</developer>
        <publisher>EA Games</publisher>
      </game>
    </games>
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:element name="games">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="game">
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element name="name" type="xsd:string" />
                  <xsd:element name="platform" type="xsd:string" />
                  <xsd:element name="price" type="xsd:decimal" />
                  <xsd:element name="developer" type="xsd:string" />
                  <xsd:element name ="publisher" type="xsd:string" />
                </xsd:sequence>
              </xsd:complexType>
            </xsd:element>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="games">
        <html>
          <head>
            <title>Revision</title>
          </head>
          <style type="text/css">
            * { font-family: Arial; }
            div div { background-color: Gray; padding: 5px; }
            b { color: RGB(100,0,0); }
          </style>
          <body>
            <xsl:for-each select="game">
              <xsl:sort select="name" order="ascending"/>
              <div>
                <h2>
                  <b>Title: </b>
                  <xsl:value-of select="name"/>
                </h2>
                <div>
                  <b>Platform: </b>
                  <xsl:value-of select="platform"/>
                </div>
                <div>
                  <b>Price: </b>
                  <xsl:value-of select="price"/>
                </div>
                <div>
                  <b>Developer: </b>
                  <xsl:value-of select="developer"/>
                </div>
                <div>
                  <b>Publisher: </b>
                  <xsl:value-of select="publisher"/>
                </div>
              </div>
            </xsl:for-each>
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>
    I would like to somehow embed the outcome of the data into an XHTML document.
    Last edited by webguy08; 06-12-2009 at 11:47 PM.

  • #4
    Regular Coder
    Join Date
    Mar 2008
    Posts
    136
    Thanks
    39
    Thanked 1 Time in 1 Post
    Anyone?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •