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!

newb question - XML + XSL not displaying!

Status
Not open for further replies.

rogue8649

MIS
Aug 29, 2001
3
US
OK, I am rather new to XML, but I have very extensive knowledge of CSS, HTML, CF, etc...IOW, new to XML, not the environment. Just clarifying :)

I am working on a very simple sheet that will display static info, and for some reason I can't get it to work correctly. Would someone please tell me if it's ME or the lack of support in IE 5.5 or what. Thank you very much!!!

______________________style.xsl___________________
<xsl:stylesheet version=&quot;1.0&quot;
xmlns:xsl=&quot; xmlns:html='
<xsl:template match=&quot;/&quot;>
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>

<xsl:template match=&quot;Rgallery&quot;>
<b class=&quot;banner&quot;><xsl:value-of select=&quot;Name&quot;/></b>
</xsl:template>

<xsl:template match=&quot;Rgallery/Section/Links&quot;>
<ul>
<xsl:for-each select=&quot;html:a&quot;>
<li>
<xsl:apply-templates />
</li>
</xsl:for-each>
</ul>
</xsl:template>

</xsl:stylesheet>
__________________________________________________________


_______________________main.xml_______________________

<?xml: version=&quot;1.0&quot;?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;style.xsl&quot;?>
<?xml-stylesheet type=&quot;text/css&quot; href=&quot;style.css&quot;?>
<Rgallery>
<Name>RGALLERY.COM</Name>
<Section>
<Links xmlns:html=' <html:a href=' Index</html:a>
<html:a href=' <html:a href=' <html:a href=' <html:a href=' <html:a href=' <html:a href=' </Links>
</Section>
</Rgallery>
_______________________________________________________

Thanks so much..I know it's probably a simple answer, but I'm at a loss....

Matt
 
My apologies, but to clarify, the LIST items are not displaying at all. It simply displays a blank page.
 
i'm not to sure about the structure of the doc but i can't really say where it breaks down :)
you could try...

<xsl:template match=&quot;Rgallery&quot;>
<b class=&quot;banner&quot;><xsl:value-of select=&quot;Name&quot;/></b>
<xsl:apply-templates select=&quot;Section/Links&quot;/>
</xsl:template>

<xsl:template match=&quot;Links&quot;>
<ul>
<xsl:for-each select=&quot;html:a&quot;>
 <li>
  <a><xsl:value-of select=&quot;.&quot;>
</a>
 </li>
</xsl:for-each>
</ul>
</xsl:template>

in the original code, when you template match the &quot;Rgallery/Section/Links&quot;, i don't think this can be done when you've already matched &quot;RGallery&quot;. certainly the way xsl is designed is to call a new apply-templates from the node, and that's how you traverse down the tree. To skip the over the &quot;Section&quot; node i've put in a select.

then in the template for &quot;Links&quot; i've left things pretty much as they are. the apply-templates inside the for-each is incorrect tho. this will try to apply-templates to the children of each &quot;html:a&quot; and not to the &quot;html:a&quot; itself.

you could also do it like this...

<xsl:template match=&quot;Links&quot;>
<xsl:apply-templates/>
</xsl:template>

<xsl:template match=&quot;html:a&quot;>
 <li>
  <xsl:apply-templates />
 </li>
</xsl:template>

note: in the template for &quot;html:a&quot; the last apply-templates will try to match a template on the link itself, but because after you take away the <html:a> tags there's nothing to match then just the name of the link will be written.

the output of what i've done here doesn't include any html tags, it will just print the link names as a list - just to keep the code compact :)

i hope i haven't confused you more now ;)
 
Thanks so much. I still can't get the LINKS to activate, but at least the pages LIST now and it's not blank!! Thanks again!

Matt
 
to print a link you'd do


<xsl:template match=&quot;html:a&quot;>
 <li>
<a href=&quot;{@href}&quot;>
   <xsl:apply-templates />
</a>
 </li>
</xsl:template>

the bit in the {} is an xpath expression, in this case it just matches the attribute href from your links.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top