Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Why won't this XML code work? URGENT HELP NEEDED!!!

Why won't this XML code work? URGENT HELP NEEDED!!!

Scheduled Pinned Locked Moved XML / XSL
xmlhtmlhelpquestionlearning
14 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R R0ssini

    I'm trying to add some XSL to my XML page. I have checked my CXSL code with XMLSpy and it's well formed. I insert the following line which works fine when I open up the XML file on it's own: However, when I try openoing up my whole html document, it doesn't work. The table comes up, but there's no colour, border adjustments, nothing! Why is this? I've checked websites and even a book and they all say this code is correct. I want to get my XSL inside the HTML file but for some reason it isn't letting me. I have to hand this work in tomorrow morning so please help me quick!

    C Offline
    C Offline
    Curtis Schlak
    wrote on last edited by
    #5

    When you post XML/(X)HTML documents, you need to change all the < to < and > to >. Or, you can just check the "Ignore HTML tags in this message (good for code snippets)" checkbox below the textarea. If you post it again, I can take a look at it and maybe help you. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

    R 3 Replies Last reply
    0
    • C Curtis Schlak

      When you post XML/(X)HTML documents, you need to change all the < to < and > to >. Or, you can just check the "Ignore HTML tags in this message (good for code snippets)" checkbox below the textarea. If you post it again, I can take a look at it and maybe help you. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

      R Offline
      R Offline
      R0ssini
      wrote on last edited by
      #6

      This code won't work for my XML file. i don't know why. The actual table is being displayed fine but it isn't aligned to the middle and the text and border should be in colour. Hope you can help! :)

      C 1 Reply Last reply
      0
      • C Curtis Schlak

        When you post XML/(X)HTML documents, you need to change all the < to < and > to >. Or, you can just check the "Ignore HTML tags in this message (good for code snippets)" checkbox below the textarea. If you post it again, I can take a look at it and maybe help you. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

        R Offline
        R Offline
        R0ssini
        wrote on last edited by
        #7

        Curtis, in case you've gone out and i'm not here by the time you reply i'll post up my whole code. Maybe you could see what's wrong? My html file is: Untitled Document

        Title

        Artist

        Country

        Company

        Price

        Year

        1 Reply Last reply
        0
        • C Curtis Schlak

          When you post XML/(X)HTML documents, you need to change all the < to < and > to >. Or, you can just check the "Ignore HTML tags in this message (good for code snippets)" checkbox below the textarea. If you post it again, I can take a look at it and maybe help you. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

          R Offline
          R Offline
          R0ssini
          wrote on last edited by
          #8

          Untitled Document

          Title

          Artist

          Country

          Company

          Price

          Year

          R 1 Reply Last reply
          0
          • R R0ssini

            Untitled Document

            Title

            Artist

            Country

            Company

            Price

            Year

            R Offline
            R Offline
            R0ssini
            wrote on last edited by
            #9

            - Voodoo Child Jimmy Hendrix USA Columbia 9.99 2000 The Wall Pink Floyd USA A and M 14.99 1986 London Calling Clash UK Virgin 13.99 1984 Hotel California The Eagles USA Island 9.99 1990 Shout Tears For Fears UK Columbia 12.99 1984 Blue Monday New Order UK A and M 10.99 1987 Singles The Smiths UK Virgin 12.99 1996 She Sells Sanctuary The Cult USA Island 14.99 1989

            R 1 Reply Last reply
            0
            • R R0ssini

              - Voodoo Child Jimmy Hendrix USA Columbia 9.99 2000 The Wall Pink Floyd USA A and M 14.99 1986 London Calling Clash UK Virgin 13.99 1984 Hotel California The Eagles USA Island 9.99 1990 Shout Tears For Fears UK Columbia 12.99 1984 Blue Monday New Order UK A and M 10.99 1987 Singles The Smiths UK Virgin 12.99 1996 She Sells Sanctuary The Cult USA Island 14.99 1989

              R Offline
              R Offline
              R0ssini
              wrote on last edited by
              #10

              My CD Collection

              Title

              Artist

              1 Reply Last reply
              0
              • R R0ssini

                This code won't work for my XML file. i don't know why. The actual table is being displayed fine but it isn't aligned to the middle and the text and border should be in colour. Hope you can help! :)

                C Offline
                C Offline
                Curtis Schlak
                wrote on last edited by
                #11

                Okay, lots of things. First, using an XML datasource in IE to populate a table (as in your HTML file) will not apply the stylesheet to the XML data. Instead, you must put your styles in the TABLE with the DATASRC. Second, using what you posted, your stylesheet has some incorrect values in it. Remember, XML is case-sensitive. Thus, "cd" and "CD" are different. Here's a stylesheet that will do what you want for the XML file. XSL file <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/">   <html>   <body>   <h2>My CD Collection</h2>    <table border="1">       <tr bgcolor="#9acd32">         <th align="left">Title</th>         <th align="left">Artist</th>       </tr>       <xsl:for-each select="/CATALOG/CD">       <tr>         <td><xsl:value-of select="./TITLE"/></td>         <td><xsl:value-of select="./ARTIST"/></td>     <td><xsl:value-of select="./COUNTRY"/></td>     <td><xsl:value-of select="./COMPANY"/></td>     <td><xsl:value-of select="./PRICE"/></td>     <td><xsl:value-of select="./YEAR"/></td>       </tr>       </xsl:for-each>     </table>   </body>   </html> </xsl:template> </xsl:stylesheet> "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

                R 1 Reply Last reply
                0
                • C Curtis Schlak

                  Okay, lots of things. First, using an XML datasource in IE to populate a table (as in your HTML file) will not apply the stylesheet to the XML data. Instead, you must put your styles in the TABLE with the DATASRC. Second, using what you posted, your stylesheet has some incorrect values in it. Remember, XML is case-sensitive. Thus, "cd" and "CD" are different. Here's a stylesheet that will do what you want for the XML file. XSL file <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/">   <html>   <body>   <h2>My CD Collection</h2>    <table border="1">       <tr bgcolor="#9acd32">         <th align="left">Title</th>         <th align="left">Artist</th>       </tr>       <xsl:for-each select="/CATALOG/CD">       <tr>         <td><xsl:value-of select="./TITLE"/></td>         <td><xsl:value-of select="./ARTIST"/></td>     <td><xsl:value-of select="./COUNTRY"/></td>     <td><xsl:value-of select="./COMPANY"/></td>     <td><xsl:value-of select="./PRICE"/></td>     <td><xsl:value-of select="./YEAR"/></td>       </tr>       </xsl:for-each>     </table>   </body>   </html> </xsl:template> </xsl:stylesheet> "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

                  R Offline
                  R Offline
                  R0ssini
                  wrote on last edited by
                  #12

                  Thank you Curtis, the code works fine :) I should be alright now but i'll let you know if I have anymore problems. Thanks for your help!

                  C 1 Reply Last reply
                  0
                  • R R0ssini

                    Thank you Curtis, the code works fine :) I should be alright now but i'll let you know if I have anymore problems. Thanks for your help!

                    C Offline
                    C Offline
                    Curtis Schlak
                    wrote on last edited by
                    #13

                    'T was my pleasure. Happy coding! "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

                    1 Reply Last reply
                    0
                    • R R0ssini

                      Some expert must be there to help me surely? I'm really panicking over this. Even if you don't think you're right could someone please suggest something?

                      M Offline
                      M Offline
                      maheshfour
                      wrote on last edited by
                      #14

                      while posting click the ignore html tags check box at the bottom of the post :-) hope it works

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups