Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

xsl and outputing <tr> or <td> to


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

Recommended Posts

Posted

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

Posted

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>...

Posted

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

Posted

<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 ....

Posted

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"?

Posted

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

Posted

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!))

Posted

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>

Posted

... 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 ...

Posted

welcome back.grin.gif

It might help troubleshootig XSLT if provided with a bit more lines than just the one not working ...

i take it does work now, does it?

This topic is 7858 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.