problem with xslt transformation

Discussion in 'XML' started by Pathik, Mar 27, 2007.

  1. Pathik

    Pathik Guest

    Hi All,

    I am New to xml. Currently I am trying to transform one xml file to
    another file using xslt

    my xml file is as follows:

    <?xml version="1.0" encoding="UTF-8" ?>
    <?xml-stylesheet type="text/xml" href="test.xsl" version="2.0"?>
    <Data>
    <Header>
    <ID>JD014</ID>
    <Test>true</Test>
    </Header>
    </Data>

    and xsl file is as follows:test.xsl

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/
    Transform">
    <xsl:template match="/">
    <xsl:for-each select="Header">
    <xsl:value-of select="ID"></xsl:value-of>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

    I m trying to print the value of ID in output . But instead of
    transformation Internet explorer simply
    shows input file as it is.

    Please check this and let me know where i am wrong.

    Thanks and Regards,
    Pathik
     
    Pathik, Mar 27, 2007
    #1
    1. Advertising

  2. * Pathik wrote in comp.text.xml:
    >Hi All,
    >
    >I am New to xml. Currently I am trying to transform one xml file to
    >another file using xslt
    >
    >my xml file is as follows:
    >
    ><?xml version="1.0" encoding="UTF-8" ?>
    ><?xml-stylesheet type="text/xml" href="test.xsl" version="2.0"?>
    ><Data>
    > <Header>
    > <ID>JD014</ID>
    > <Test>true</Test>
    > </Header>
    ></Data>
    >
    >and xsl file is as follows:test.xsl
    >
    ><?xml version="1.0" encoding="UTF-8"?>
    ><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/
    >Transform">
    ><xsl:template match="/">
    ><xsl:for-each select="Header">
    > <xsl:value-of select="ID"></xsl:value-of>
    ></xsl:for-each>
    ></xsl:template>
    ></xsl:stylesheet>
    >
    >I m trying to print the value of ID in output . But instead of
    >transformation Internet explorer simply
    >shows input file as it is.


    Internet Explorer does not support XSLT 2.0 and the xml-stylesheet
    processing instruction does not have a version pseudo-attribute.
    Further, <xsl:template match="/"> matches the document node, not
    the root element node, so your for-each would select no nodes as
    there are no "Header" elements that are children of the document
    node.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
     
    Bjoern Hoehrmann, Mar 27, 2007
    #2
    1. Advertising

  3. Pathik wrote:

    > <Data>
    > <Header>
    > <ID>JD014</ID>
    > <Test>true</Test>
    > </Header>
    > </Data>
    >
    > and xsl file is as follows:test.xsl
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/

    ^^^^^^^^^^^^^
    Use version="1.0" for IE or other browsers as XSLT 2.0 is too new to be
    supported by browsers. While the XSLT processor will try to process the
    stylesheet even for a not supported version (so called forwards
    compatible processsing <http://www.w3.org/TR/xslt#forwards>) you do not
    help yourself understanding normal XSLT transformation if you run
    stylesheet that way.

    > Transform">
    > <xsl:template match="/">


    Inside a browser you usually want to transform XML to HTML so best
    practice is to include the necessary elements making up a HTML document e.g.
    <html>
    <head>
    <title>XSLT test</title>
    </head>
    <body>

    > <xsl:for-each select="Header">


    The Header element is a child of the Data element so you need
    <xsl:for-each select="Data/Header>

    > <xsl:value-of select="ID"></xsl:value-of>
    > </xsl:for-each>

    </body>
    </html>
    > </xsl:template>




    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Mar 27, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0Qw==?=

    Xslt Transformation getting &lt; and &gt;

    =?Utf-8?B?UGF0Qw==?=, May 13, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    869
    Steven Cheng[MSFT]
    May 19, 2004
  2. Wolfgang
    Replies:
    2
    Views:
    842
    Wolfgang
    Apr 9, 2004
  3. Wolfgang
    Replies:
    0
    Views:
    425
    Wolfgang
    Apr 6, 2004
  4. Pathik
    Replies:
    1
    Views:
    473
  5. bosesuparna
    Replies:
    0
    Views:
    964
    bosesuparna
    Nov 25, 2011
Loading...

Share This Page