XSLT/XML --> XHTML

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

XSLT/XML --> XHTML

Post by Chris Corbyn »

Awesome... I've just started playing around with this :oops: What have a been missing out on!?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

uhhhhh what is it? i don't know what a have been missing out on :P
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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"/>
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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>
Post Reply