Solved

for-each loop in XSLT

Posted on 2013-06-30
4
497 Views
Last Modified: 2013-07-04
Hi All,

I'm trying to store variable with in for-each loop, it's working fine, but due to low performance, i like to ignore for-each loop, any other alternative way for this:

<xsl:template match="w:tbl">

<tgroup>

<!-- even single cell does not have w:tcBorders, don't pass frame='r'-->

<xsl:variable name="borderRight"><xsl:for-each select="w:tr/w:tc[last()]/w:tcPr"><xsl:if test="not(w:tcBorders/w:right[@w:val='single'])">no</xsl:if></xsl:for-each></xsl:variable>

<xsl:attribute name="frame"><xsl:if test="string-length($borderRight)=0">r</xsl:if></xsl:attribute>

</xsl:template>

Can I use KEY in this case? and how to use KEY?


Thanks in Advance,


Regards,
Saran
0
Comment
Question by:xedge88
  • 2
  • 2
4 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 39289196
you have no identifier or anything to key in the last cell

for-each in a variable is not a good idea, not because of the performance, but because of the fact that it returns you a sequence

Can you explain in words what you try to do?
Context is important. Is this the template for a word table?
When do you want the borderRight?

string-length also is an unnecessary burden on performance here, check for nodes

No variable required, I think this si what you need

<xsl:attribute name="frame">
<xsl:if test="not(w:tr/w:tc[last()]/w:tcPr[not(w:tcBorders/w:right[@w:val='single'])])">r</xsl:if>
</xsl:attribute>
0
 

Author Comment

by:xedge88
ID: 39289244
Hi Gertone,

Thanks for quick reply,

Can you explain in words what you try to do?
Ans: Docx to CaLsTable convert

When do you want the borderRight?
Ans: if all the last cell applied w:right[@w:val='single'], i should pass attribute in <tgroup frame="r">

even single cell does not have right rules, don't want frame='r'

Regards,
Saran
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 39289253
Word to Cals... I had a suspicion
(good luck when calculating the spans :-)

I believe what I sent does what you need
0
 

Author Comment

by:xedge88
ID: 39299325
Thanks for best solution
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question