Page 1 of 1

XSLT/XML --> XHTML

Posted: Sat Apr 15, 2006 7:07 pm
by Chris Corbyn
Awesome... I've just started playing around with this :oops: What have a been missing out on!?

Posted: Sat Apr 15, 2006 7:12 pm
by shiznatix
uhhhhh what is it? i don't know what a have been missing out on :P

Posted: Sat Apr 15, 2006 7:41 pm
by timvw
Things that i remember from playing with it:

(The syntax higlighter seems to be still broken...)

The following does NOT work:

Code: Select all

<form action="<xsl:value-of select="/page/action"/>" method="post">
The solution:

Code: Select all

<form action="{/page/action}" method="post"></form>
When building lists, make sure they are not empty (eg:)

Code: Select all

<xsl:if test="count(items/item) > 0">
  <ul>
    <xsl:for-each select="items/item">
    <li><a href="{link}"><xsl:value-of select="title"/></a></li>
    </xsl:for-each>
  </ul>
</xsl:if>
If you don't want the xml version of htmlentities on your data use disable-output-escaping="yes"

Code: Select all

<xsl:value-of select="attribute[@name='content']" disable-output-escaping="yes"/>
Some versions of php use to transform <textarea></textarea> to <textarea/> to avoid this:

Code: Select all

<xsl:output method="html"/>

Posted: Sun Apr 16, 2006 5:24 am
by Chris Corbyn
timvw wrote:Things that i remember from playing with it:

(The syntax higlighter seems to be still broken...)

The following does NOT work:

Code: Select all

<form action="<xsl:value-of select="/page/action"/>" method="post">
The solution:

Code: Select all

<form action="{/page/action}" method="post"></form>
When building lists, make sure they are not empty (eg:)

Code: Select all

<xsl:if test="count(items/item) > 0">
  <ul>
    <xsl:for-each select="items/item">
    <li><a href="{link}"><xsl:value-of select="title"/></a></li>
    </xsl:for-each>
  </ul>
</xsl:if>
If you don't want the xml version of htmlentities on your data use disable-output-escaping="yes"

Code: Select all

<xsl:value-of select="attribute[@name='content']" disable-output-escaping="yes"/>
Some versions of php use to transform <textarea></textarea> to <textarea/> to avoid this:

Code: Select all

<xsl:output method="html"/>
Handy to know thanks :)
shiznatix wrote:uhhhhh what is it? i don't know what a have been missing out on :p
XML I'm sure you know. XSLT allows you to transform XML (or rather XSL) into other formats such as HTML or XHTML (or even another XML document). I've stumbled upon using it as a means of making my markup more readable and smaller in size since what I'm doing at the moment is a little obscure.

http://www.w3schools.com/xsl/default.asp

Posted: Mon Apr 17, 2006 6:37 pm
by Chris Corbyn
timvw wrote:Things that i remember from playing with it:

(The syntax higlighter seems to be still broken...)

The following does NOT work:

Code: Select all

<form action="<xsl:value-of select="/page/action"/>" method="post">
The solution:

Code: Select all

<form action="{/page/action}" method="post"></form>
You can actually just add attribute using XSLT inline in any case ;)

Code: Select all

<form method="post">
<xsl:attribute name="action">
<xsl:value-of select="/page/action"/>
</xsl:attribute>