Jump to content
Server Maintenance This Week. ×

xsl and outputing <tr> or <td> to


pelegk

This topic is 7658 days old. Please don't post here. Open a new topic instead.

Recommended Posts

i am trying to do this :

<xsl:if test="position() mod 2!=0">

<xsl:value-of select="&#60;"/>

<xsl:value-of select="tr" />

<xsl:value-of select="&#62;"/>

</xsl:if>

or

<xsl:if test="position() mod 2!=0">

<xsl:value-of select="&lt;"/>

<xsl:value-of select="tr" />

<xsl:value-of select="&gt;"/>

</xsl:if>

but no one of this work's!

when i try to run it i get i have an error "expression expected" : "--><<--

what can i do to over ride this problem?

thanks in advance

PEleg

Link to comment
Share on other sites

just take the instruction literally - is there any XML node named "&gt;" which the script should select? Or do you just want to include some [xsl:]text here...

<xsl:text>&gt;</xsl:text>

Or may be you want an XML/HTML element named "tr":

<xsl:element name="tr">sample text</xsl:element>....

since you are dealing with a template, why not include

<tr><xsl:value-of select="table/header/col1" /></tr>...

Link to comment
Share on other sites

ok maybe i didn't explain my self correct :

i want to do and if sentence that once will print <tr> and once <td>

and of course will close this tags!

the problem is when i try to do :

<xsl:if test="position() mod 2 =0">

<TR>

</xsl:if>

it tells me tag <xsl:if> dont match start tag <tr>

beacuse of that everyhing i tried didnt work!

what to do?

thnaks in advance

peleg

Link to comment
Share on other sites

<xsl:if test="position() mod 2 =0">

<TR><TD>tablerow even</TD></TR>

</xsl:if>

<xsl:if test="position() mod 2 =1">

<TR><TD>tablerow odd</TR></TR>

</xsl:if>

xml/html must be well-formed, eg, you will have to close the <TR>tag before closing the <xsl:if> tag ....

Link to comment
Share on other sites

yes but the problem is this :

in the start of the code :

<xsl:if test="position() mod 2 =0">

<TR>

</xsl:if>

.....

code.....

<xsl:if test="position() mod 2 =0">

</TR>

</xsl:if>

but this isnt working!

what u gave me dont help me!

what lse can i do"?

Link to comment
Share on other sites

you will have to use correct nesting of tags. no way around it.

use

<xsl:if test="position() mod 2 =0">

<TR>thecomplete tablerow</TR>

</xsl:if>

and then

<xsl:if test="position() mod 2 =1">

<TR>thecompletetablerow again</TR>

</xsl:if>

it's not that difficult to repeat the text between <TR> and </TR> since most computers have copy & paste nowadays .... grin.gif

Link to comment
Share on other sites

i knew that but i didnt want double code( same code ) on my page!

beacuse of that i have posted that question hee from the begining!

may god bless us all

and speically the ones who fight th Terorist ( like arafat!))

Link to comment
Share on other sites

Well, then try either ignoring the basic rules of processing XML and make up your own(the WW3C is an international body, after all ..) or learn to analyse your problem a bit further.

<TR>

Link to comment
Share on other sites

... and while you are editing your prefs, can you take back the thread's rating? This thread doesn't deserve a 5 star rating - we have both not been very intelligent here ...

Link to comment
Share on other sites

This topic is 7658 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.