XSLT help!!!
I am having trouble with using XSLT. It's confusing as to why but basically I have valid html and I am transforming it to my own xml. What I want to do is the following:
I have an html table. There are many elements in a <td> element.
For example it may look like this:
<td>
<p>this is a test</p>
<br/>
<a href="link">this is a link</a>
<a href="link2">this is another link</a>
<br/>
<br/>
</td>
What I want to do is that everytime there is a <br/>, end the current panel and start a new panel.
So it would look like:
<surroundingTag>
<myOwnTag>
<p>this is a test</p>
</myOwnTag>
<myOwnTag>
<a href="link">this is a link</a>
<a href="link2">this is another link</a>
</myOwnTag>
<myOwnTag>
</myOwnTag>
</surroundingTag>
Right now I have this:
...
<xsl:template match="tr">
<xsl:for-each select=".">
<surroundingTag>
<xsl:apply-templates select="td"/>
</surroundingTag>
</xsl:for-each>
</xsl:template>
<xsl:template match="td">
<xsl:for-each select=".">
<myOwnTag>
<xsl:apply-templates/>
</myOwnTag>
</xsl:for-each>
</xsl:template>
I want to do something like this...although I know it doesn't work. When a <br/> is read. I want to close the current tag by </myOwnTag>, then start a new tag by <myOwnTag>...
<xsl:template match="//table//br">
</myOwnTag>
<myOwnTag>
</xsl:template>
I know that doesn't work. I am new to this. Any ideas how to accomplish this??
Any help is appreciated. Thanks!
|