Answered XSLT Processor

  • Friday, August 10, 2012 1:35 PM
     
     

    I want to display my XML file as HTML.  I have a corresponding XSL file.  I have included the reference to the XSL file inthe XML file.  I'm using Internet Explorer 8, but when I open the XML file, I just get the XSL file without the data contained in the XML file. 

    XML:

    <?xml version="1.0" encoding="utf-8"?>
    <?xml-stylesheet type="text/xsl" href="C:\Path\Form1.xsl"?>
    <ParameterXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Name>Form1</Name>
      <Description>Reference</Description>
      <Note />
      <ValueNote />
      <TypeId>12</TypeId>
      <DataFileId>0</DataFileId>
    </ParameterXml>

    XSL:

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
      <html>
      <body>
      <h2>Parameter:     <xsl:value-of select="Name"/></h2>
      <h3>Description:    <xsl:value-of select="Description"/></h3>
      <h3>Note:              <xsl:value-of select="Note"/></h3>
      <h3>ValueNote:     <xsl:value-of select="ValueNote"/></h3>
      <h3>TypeId:           <xsl:value-of select="TypeId"/></h3>
      <h3>DataFileId:      <xsl:value-of select="DataFileId"/></h3>
      </body>
      </html>
    </xsl:template>

    </xsl:stylesheet>

    Can anyone help me out?

    John

All Replies

  • Friday, August 10, 2012 3:07 PM
     
     Answered

    I discovered the problem.

    The answer lies in the stylesheet.  The Name, Description, Note, ValueNote, TypeId and DataFileId are part of the ParameterXml structure, so I need to specify the path in the <<value-of>> statement.  Instead of writing  <xsl:value-of select="Name"/>, for example, I should have written  <xsl:value-of select="ParameterXml/Name"/>.

    John

    • Marked As Answer by JohnOnMsdn Friday, August 10, 2012 3:08 PM
    •