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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl:value-of in html embed attribute

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
In the code below I'm trying to create a page of embeded controls that have "structure" attributes from my xml file.
The parser tells me I must supply a quote after "structure="
but whichever way I try it, the quoted string isn't getting in my html.

Cheers.

<xsl:stylesheet xmlns:xsl=&quot; <xsl:template match=&quot;/&quot;>
<HTML>
<BODY>
<xsl:for-each select=&quot;DesignProjectHistory/Sets/Set1/Reagents/R/&quot;>
<embed type=&quot;chemical/x-mdl-molfile&quot;
structure= <xsl:value-of select=&quot;CHIMESTRING&quot;/>
bgcolor=&quot;white&quot;
display2d=&quot;true&quot;
color=&quot;black&quot;
height=&quot;300&quot;
width=&quot;300&quot;>
</embed>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
 
Hello voodoo boy,
The problem is that you are trying to set an attribute for an XML element <embed>.
(Well, it is a HTML element, but as you are using it in XML file, it is an XML element.)
Adding attributes is simple when you use constants -they have to be surronded by &quot;&quot;.
When you want to add attribute which have to use some new command, then it is possible with the following construct:

<embed type=&quot;chemical/x-mdl-molfile&quot; bgcolor=&quot;white&quot; display2d=&quot;true&quot; color=&quot;black&quot; height=&quot;300&quot; width=&quot;300&quot;>
<xsl:attribute-set name=&quot;structure&quot;>
<xsl:value-of select=&quot;CHIMESTRING&quot;/>
</xsl:attribute-set>
</embed>

or

<embed type=&quot;chemical/x-mdl-molfile&quot; bgcolor=&quot;white&quot; display2d=&quot;true&quot; color=&quot;black&quot; height=&quot;300&quot; width=&quot;300&quot;>
<xsl:attribute-set name=&quot;structure&quot; value=&quot;CHIMESTRING&quot;/>
</embed>


The idea is that all &quot;constant&quot; pairs attribute=&quot;value&quot; are in the beginning, then only the attribute which has to have the value is added (in first example only name of the attrubute is given, and the automatic value is added with what is between staring and closing tag, and in the second way attribute explicitely is set with name and value.)

I would recommend XSLT tutorial on:

Hope this helps, D.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top