Topic
3 replies Latest Post - ‏2010-08-01T03:25:52Z by SystemAdmin
GrexP
GrexP
1 Post
ACCEPTED ANSWER

Pinned topic Newbie: XSL value-of select not working

‏2010-07-30T17:04:51Z |
My first XSL file. I'm in Dreamweaver and the code is below. There are 3 <h*1> blocks. The first 2 appear on the page, but the one in the for-each block does not, so that is not firing. None of the value-of items appear. There are values for them in the XML file and I get no errors.

I'm sure it is simple, but I am stumped

Greg

<?xml version=
"1.0" encoding=
"iso-8859-1"?><!-- DWXMLSource=
"CCDTest.xml" --><!DOCTYPE xsl:stylesheet  [ <!ENTITY nbsp   
" "> <!ENTITY copy   
"©"> <!ENTITY reg    
"®"> <!ENTITY trade  
"™"> <!ENTITY mdash  
"-"> <!ENTITY ldquo  
"""> <!ENTITY rdquo  
"""> <!ENTITY pound  
"£"> <!ENTITY yen    
"¥"> <!ENTITY euro   
"€"> ]> <xsl:stylesheet version=
"1.0" xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"> <xsl:output method=
"html" encoding=
"iso-8859-1" doctype-public=
"-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system=
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> <xsl:template match=
"/"> <html> <body> <h1>Problems</h1>     <meta http-equiv=
"Content-Type" content=
"text/html; charset=iso-8859-1"/> <h1>Untitled Document</h1> <h2><xsl:value-of select=
"ContinuityOfCareRecord/Body/FunctionalStatus/Function/Type/Text"/></h2>   <xsl:for-each select=
"ContinuityOfCareRecord/Body/Problems/Problem/DateTime/Type/Text"> <h1>Test</h1> <xsl:value-of select=
"Text" />   </xsl:for-each>     </body> </html>   </xsl:template> </xsl:stylesheet>
Updated on 2010-08-01T03:25:52Z at 2010-08-01T03:25:52Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1391 Posts
    ACCEPTED ANSWER

    Re: Newbie: XSL value-of select not working

    ‏2010-07-31T12:40:30Z  in response to GrexP
    The for-each loop implies you should have a tree like this near the end of the xpath:
    
    ...<Text>...<Text>...</Text>...</Text>...
    

    I guess it is not what you mean for. Hence, I guess you mean just this?
    
    <xsl:for-each select=
    "ContinuityOfCareRecord/Body/Problems/Problem/DateTime/Type/Text"> <h1>Test</h1> <xsl:value-of select=
    "." /> </xsl:for-each>
    

    It makes the body of something of a mixed content type. Those data stand out as text under body tag.
  • sdfgsdfgzxcvzxcvzxcv
    1 Post
    ACCEPTED ANSWER

    Re: Newbie: XSL value-of select not working

    ‏2010-07-31T18:40:16Z  in response to GrexP
    How would I deal with the situation below? I have a single <medications> tag with
    one or more <medication> blocks. Wouldn't I use a for-each loop on the top level
    <medications> to display each <medication> section?


    <Medications>
    <Medication>
    <CCRDataObjectID>MEDICATION.28189</CCRDataObjectID>
    <Product>
    <ProductName>
    <Text>pramipexole</Text>
    </ProductName>
    <BrandName>
    <Text>Mirapex</Text>
    </BrandName>
    <Strength>
    <Value>0.125</Value>
    </Product>
    </Medication>

    <Medication>
    <CCRDataObjectID>MEDICATION.28188</CCRDataObjectID>
    <Product>
    <ProductName>
    <Text>sulfamethoxazole-trimethoprim</Text>
    </ProductName>
    <BrandName>
    <Text>Bactrim DS</Text>
    </BrandName>
    <Strength>
    <Value>800</Value>
    </Strength>
    </Medication>
    </Medications>
    • SystemAdmin
      SystemAdmin
      1391 Posts
      ACCEPTED ANSWER

      Re: Newbie: XSL value-of select not working

      ‏2010-08-01T03:25:52Z  in response to sdfgsdfgzxcvzxcvzxcv
      >to display each <medication> section
      It depends on what is desired to "display". What is it? maybe then we can suggest some idea.
      You can use for-each, you can use template(s)... and then it depends on the context node etc.