Solved

for-each loop in XSLT

Posted on 2013-06-30
4
504 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

738 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