Jump to content

using xml and xsl example...


Guest ethanfink

Recommended Posts

Guest ethanfink

i am using the xml and xsl examples off of this page:http://www.w3schools.com/xml/xml_xsl.aspi am trying to make links in the "used" nob, but when I use cdata against them they come out as text instead of html code. Any thoughts on how to get these to be links?xml code:<?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited with XML Spy v2006 (http://www.altova.com) --><?xml-stylesheet type="text/xsl" href="simple.xsl" ?><menu><ingredient><name>10-Hydroxydecanoic Acid</name><link>treatment_scalp</link><description>An exfolient that dissipates and regulates the elimination of dead scalp cells while helping to control the amount of sebum on the skin.</description><used><![CDATA[<a href="link.html">link1</a>, <a href="link2.html">link2</a>]]></used></ingredient><ingredient><name>10-Hydroxydecanoic Acid</name><link>treatment_scalp</link><description>An exfolient that dissipates and regulates the elimination of dead scalp cells while helping to control the amount of sebum on the skin.</description><used><![CDATA[<a href="link.html">link1</a>, <a href="link2.html">link2</a>]]></used></ingredient></menu>xls code:<?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited with XML Spy v2006 (http://www.altova.com) --><html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"><body style="color:#666666; line-height: 1.5; font-family: verdana, sans-serif; font-size: 10px;background-color:#EEEEEE"><xsl:for-each select="menu/ingredient"><div style="background-color:white;color:black;padding:4px"><span style="font-weight:bold;color:black"><xsl:value-of select="name"/></span><br></br></div><div style="margin-left:20px;margin-bottom:1em;font-size:10pt line-height: 1.5; font-family: verdana, sans-serif; font-size: 10px;"><xsl:value-of select="description"/><br></br><span style="font-style:italic; line-height: 1.5; font-family: verdana, sans-serif; font-size: 10px;"><xsl:value-of select="used"/></span></div></xsl:for-each></body></html>also this data is going to be needed to be placed in a table in an html or xhtml page with data around it in the other tables, what would be the best was to import this into another document?

Link to comment
Share on other sites

Having a CDATA is equivalent to having an element with no childs but only text. So

<used><![CDATA[<a href="link.html">link1</a>, <a href="link2.html">link2</a>]]></used>

is the same as

<used><a href="link.html">link1</a>, <a href="link2.html">link2</a></used>

And in order to turn either into pure output with no alterations whatsoever, you must add disable-ouput-escaping="yes" to the value-of element. Not supported in Transformiix (Firefox).Example:

<xsl:value-of select="used" disable-ouput-escaping="yes"/>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...