Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

for-each loop in XSLT

Posted on 2013-06-30
4
Medium Priority
?
523 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 1500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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?
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

721 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