Solved

for-each loop in XSLT

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

615 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