Solved

for-each loop in XSLT

Posted on 2013-06-30
4
492 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now