sas_kappel
sas_kappel

Reputation: 61

XSLT issue simple

Could someone help with this issue ? :

this my xml file called ce.xml

    <?xml version="1.0" encoding="windows-1252" ?>
<?xml-stylesheet type="text/xsl" href="ce.xslt"?>
<TABLE>
   <CE>
      <Variable> STUDYID </Variable>
      <Label> Study Identifier </Label>
      <length> 200 </length>
      <Type> Char </Type>
   </CE>
   <CE>
      <Variable> DOMAIN </Variable>
      <Label> Domain Abbreviation </Label>
      <length> 200 </length>
      <Type> Char </Type>
   </CE>
 <TABLE>

I would to render in html only the values of the variable "Variable",which are domain and studyid. So I used the following xslt transformation :

    <?xml version="1.0"?>

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


<xsl:template match="/">
<html>
 <head>
   <title>Get all Variables</title>
 </head>
 <body>
  <xsl:for-each select="/TABLE/CE"/>
    <xsl:value-of select="Variable"/>
  </xsl:for-each>
 </body>
</html>
</xsl:template>

</xsl:stylesheet>

I don't understand, it should work as it is quite a basic query. Note that it failed on all browsers.

Thanks in advance

saskap

Upvotes: 0

Views: 50

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 117102

  1. Your input is not well-formed XML: the final <TABLE> needs to be </TABLE>.
  2. Instead of :

    <xsl:for-each select="/TABLE/CE"/>
    

    you need:

    <xsl:for-each select="/TABLE/CE">
    

Upvotes: 2

Related Questions