Jump to content

Improvement to XSL pages.


Steve Waring

Recommended Posts

I think the help given by W3schools is excellent, but the pages on XSL were a little sparse. I managed to work out what I needed to do, by using the reference material, but I did struggle a little.An addition that would be very welcome would be to show how to transform XML into a link. For example:

<xsl:if test="./attribute::ref != ''">   Ref: <a><xsl:attribute name="href"><xsl:value-of select="./attribute::ref" /></xsl:attribute><xsl:value-of select="./attribute::ref" /></a></xsl:if>

Other examples might be to show how to colour alternate rows in a table:

<tr>   <xsl:attribute name="style">	  <xsl:choose>		 <xsl:when test="position() mod 2 = 1">			background-color:#f0f0f0		 </xsl:when>		 <xsl:otherwise>			background-color:#e6f1f7		 </xsl:otherwise>	  </xsl:choose>   </xsl:attribute>

Link to comment
Share on other sites

Let me just generalize what you're suggesting - Explanation of attribute creation in XSLT.This is currently only covered in the XSLT FAQ which of course not everyone reads (as is with all FAQs) and I completely agree this should be added into the tutorial. I've written to kaijim for that a long time ago and it's still not done. I guess they simply haven't decided to make improvements and this will be left as is until they do.

Link to comment
Share on other sites

An addition that would be very welcome would be to show how to transform XML into a link. For example:
Isn't that covered by XLink?For those that understand Norwegian, at the top of page 3 you can read:"Et vilkårlig element kan gjøres om til link-element". Translated to English, an arbitrary element can be transformed to a link element.Related documentation:XML Linking language.For additional information, see my posts in this thread.Without knowing the details, I also think that xml:base is important in this respect - xml:base is according to my favourite PHP / XML book referred to in the posts above primarily used for XLink to describe linking between resources. You may also see it used in other contexts, such as with XInclude and XSLT.
Link to comment
Share on other sites

Isn't that covered by XLink?
No. XLink is for defining links in new XML dialects. A sort of generic linking language, the same way for example XInclude is a genertic inclusion language. What Steve Waring means to say is to transform something into an HTML link, and THAT you can't do with XLink. You may convert XLink to an HTML link though, but that's not the point here.
Link to comment
Share on other sites

You may convert XLink to an HTML link though, but that's not the point here.
Yes, via XML's transforamtion language XSL as he suggests. Templates are the key. XML without, XSL(T), XPath, XLink... is like a regatta without wind.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...