Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...What a great service! This is the best site I've ever seen!!! It totally restores my faith in humanity when people take time out to help other people..."

Geography

Where in the world do Tek-Tips members come from?
KevinDW (IS/IT--Management)
11 Apr 12 10:56
I have the following XML code:

<n-grams-sorted analysis="N_GRAM_TOKEN2" range="Total Set" types="33459" tokens="50285">
    <n-gram position="1" frequency="387" probability="0.0077">x =</n-gram>
    <n-gram position="2" frequency="319" probability="0.00634">! =</n-gram>
    <n-gram position="3" frequency="295" probability="0.00587">= [i]</n-gram>
    <n-gram position="4" frequency="286" probability="0.00569">? =</n-gram>
    <n-gram position="5" frequency="221" probability="0.00439">love =</n-gram>
    <n-gram position="6" frequency="186" probability="0.0037">. =</n-gram>
    <n-gram position="7" frequency="182" probability="0.00362">:p =</n-gram>

....

<n-gram position="90" frequency="25" probability="0.0005">? :p</n-gram>


How do you get the first 30 with a <xsl:for-each> ?

<xsl:for-each select="//n-gram[@position &lt; $position]">

 
MakeItSo (Programmer)
11 Apr 12 11:20
Hi KevinDW,

1.) Nice smilie in your code! lol

2.) This does not work this way. It seems the only way is to use a recursive template.
Found this snippet:

CODE

<xsl:template name="recurse_till_ten">
    <xsl:param name="num">1</xsl:param> <!-- param has initial value of 1 -->
    <xsl:if test="not($num = 10)">
        ...do something
        <xsl:call-template name="recurse_till_ten">
            <xsl:with-param name="num">
                <xsl:value-of select="$num + 1">
            </xsl:with-param>
        </xsl:call-template>
    </xsl:if>
</xsl:template>
Source: http://sourceware.org/ml/xsl-list/2000-08/msg01503.html

Adjust from 10 to 30 and put your processing code at the do something position.

Hope this helps.

Cheers,
MakeItSo

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.

KevinDW (IS/IT--Management)
11 Apr 12 12:05
Hey MakeItSo,

Your code helps me a lot.

But I have just one little question:

I want to select "position"
from

<n-gram position="1" frequency="387" probability="0.0077">x =</n-gram>

with

<xsl:value-of select="./position"/>

But it's not correct?
Do you know the solution for this one?

Kevin







 
MakeItSo (Programmer)
12 Apr 12 4:30
Hi Kevin,

"position" is an aatribut, so you need to address it as "@position"
winky smile

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close