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

adding xml thru xsl in html file

Status
Not open for further replies.

VIdude

Programmer
Feb 8, 2005
4
BE
Hi,
I have an xml file with xsl behind it, and would like to call the entire thing in an html file. is this possible???
Detail:
for users' sake, I use an xml file with data of pictures (name, size, height). With the xsl, I define where to display which picture. Now, I would like to use all of this in an html file which contains all other layout stuff...
Is this possible?? I read about data-islands, but it's not working...

regards
 
Yes it is possible. You can transform XML with XSLT client-side:


You can also do it server-side using ASP or similar technology.

BUT, a better way to do what you want would be just to include the HTML in the XSL file and reference this in the XML:

XML:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="myxsl.xsl"?>
<mypics>
  <image>
    <src>pic.jpg</src>
    <height>200</height>
    <width>100</width>
  </image>
</mypics>
XSL:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:template match="/">
  <html>
  <body>
    <p>This is my page</p>
    <xsl:for-each select="mypics/image">
      <img>
        <xsl:attribute name="src">
          <xsl:value-of select="src"/>
        </xsl:attribute>
        <xsl:attribute name="height">
          <xsl:value-of select="height"/>
        </xsl:attribute>
        <xsl:attribute name="width">
          <xsl:value-of select="width"/>
        </xsl:attribute>
      </img>
    </xsl:for-each>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top