Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display image w/ <img datasrc> and xml 1

Status
Not open for further replies.

pie3141516

Programmer
Mar 28, 2005
13
US
Greetings,
I am having great difficulty displaying a
Photo with a stylesheet within a table dynamically.
I believe the following line

<img datasrc="#demographics" datafld="File" border="0" alt="Patient Photo" />

is causing the problem,
but I do not know how to fix it.
Any help would be greatly appreciated.
Thanks a zillion.

My xml file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="ss.xsl"?>
<ContinuityOfCareRecord
xmlns:xsi="xsi:schemaLocation="urn:astm-org:CCR CCR_20051109.xsd"
xmlns="urn:astm-org:CCR">
<CCRDocumentObjectID>2008091400235414</CCRDocumentObjectID>
<Patient><ActorID>PATIENT_1001</ActorID></Patient>
<Actors>
<Actor>
<ActorObjectID>PATIENT_1001</ActorObjectID>
<Person>
<Name><Text>Doe</Text></Name>
<Gender><Text>Male</Text></Gender>
<Photo><File>pat_1001.bmp</File></Photo>
</Person>
</Actor>
</Actors>
</ContinuityOfCareRecord>


My stylesheet looks like this:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" xmlns:a="urn:astm-org:CCR" xmlns:date=" exclude-result-prefixes="a date">
<xsl:eek:utput method="html" encoding="UTF-8"/>
<xsl:param name="stylesheet"/>
<xsl:template match="/">
<html xmlns:date="<table id="demographics" class="list" width="50%">

<td>
<br/>
<body>
<tbody>
<tr>
<th>Name</th>
<th>Gender</th>
<th>Photo</th>
</tr>

<xsl:for-each select="a:ContinuityOfCareRecord/a:patient">
<xsl:variable name="objID" select="a:ActorID"/>
<xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor">
<xsl:variable name="thisObjID" select="a:ActorObjectID"/>

<td>
<xsl:value-of select="a:person/a:Name/a:Text"/>
</td>

<td>
<xsl:value-of select="a:person/a:Gender/a:Text"/>
</td>

<td valign="top" width="100">
<img datasrc="#demographics" datafld="File" border="0" alt="Patient Photo" /> <!-- this is the line with the problem -->
</td>

</xsl:for-each>
</xsl:for-each>


</tbody>
</body>
</td>

</table>
</html>
</xsl:template>
</xsl:stylesheet>
 
[0] Before answering the question, a short note on the markup. The html of this structure seems not good.
>[tt]
html
table
td
body
tbody
tr
[/tt]

is absolutely strangely conceived. I would say at least make it like this re-arrange the body(?) and eliminate the starting spurious(?) td: what is it?!
[tt]
html
body
table
tbody
tr
[/tt]
[1] You've made a cartesian product of each xsl:for-each... I am not saying it is a priori wrong, just that I do not see clearly your xml data fully, so I leave it alone without commenting on it.

[2] The img tag is construction like this.
><img datasrc="#demographics" datafld="File" border="0" alt="Patient Photo" />
[tt]<img [red]src="{a:person/a:photo/a:File}"[/red] border="0" alt="Patient Photo" />[/tt]

[2.1] The above, using attribute value template, may be a bit cryptic for some. This is a longer version of the same.
[tt]
<img border="0" alt="Patient Photo">
<xsl:attribute name="src">
<xsl:value-of select="a:person/a:photo/a:File" />
</xsl:attribute>
</img>[/tt]

/>[/tt]
 
You are brilliant beyond belief!
Thanks a zillion!
The syntax worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top