Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this xml :

XML
<pre lang="xml"><quran>
    <row>
        <WID>10</WID>
        <word>بسم</word>
        <SID>1</SID>
        <Ayeh>0</Ayeh>
        <Joze>1</Joze>
        <Hezb>1</Hezb>
        <ParentID>4556</ParentID>
        <Page>1</Page>
        <Joint>1</Joint>
        <SName>فاتحه</SName>
    </row>
    <row>
        <WID>11</WID>
        <word>الله</word>
        <SID>1</SID>
        <Ayeh>0</Ayeh>
        <Joze>1</Joze>
        <Hezb>1</Hezb>
        <ParentID>3565</ParentID>
        <Page>1</Page>
        <Joint>1</Joint>
        <SName>فاتحه</SName>
    </row>
    <row>
        <WID>12</WID>
        <word>الرحمن</word>
        <SID>1</SID>
        <Ayeh>0</Ayeh>
        <Joze>1</Joze>
        <Hezb>1</Hezb>
        <ParentID>2876</ParentID>
        <Page>1</Page>
        <Joint>1</Joint>
        <SName>فاتحه</SName>
    </row>
    <row>
        <WID>14</WID>
        <word>الْحَمْدُ</word>
        <SID>1</SID>
        <Ayeh>2</Ayeh>
        <Joze>1</Joze>
        <Hezb>1</Hezb>
        <ParentID>2732</ParentID>
        <Page>1</Page>
        <Joint>1</Joint>
        <SName>فاتحه</SName>
    </row>
    <row>
        <WID>15</WID>
        <word>للّهِ</word>
        <SID>1</SID>
        <Ayeh>2</Ayeh>
        <Joze>1</Joze>
        <Hezb>1</Hezb>
        <ParentID>12105</ParentID>
        <Page>1</Page>
        <Joint>1</Joint>
        <SName>فاتحه</SName>
    </row>
    <row>
        <WID>5618</WID>
        <word>بسم</word>
        <SID>2</SID>
        <Ayeh>0</Ayeh>
        <Joze>1</Joze>
        <Hezb>1</Hezb>
        <ParentID>4556</ParentID>
        <Page>2</Page>
        <Joint>2</Joint>
        <SName>بقره</SName>
    </row>
    <row>
        <WID>5619</WID>
        <word>الله</word>
        <SID>2</SID>
        <Ayeh>0</Ayeh>
        <Joze>1</Joze>
        <Hezb>1</Hezb>
        <ParentID>3565</ParentID>
        <Page>2</Page>
        <Joint>2</Joint>
        <SName>بقره</SName>
    </row>
    <row>
        <WID>5620</WID>
        <word>الرحمن</word>
        <SID>2</SID>
        <Ayeh>0</Ayeh>
        <Joze>1</Joze>
        <Hezb>1</Hezb>
        <ParentID>2876</ParentID>
        <Page>2</Page>
        <Joint>2</Joint>
        <SName>بقره</SName>
    </row>
    <row>
        <WID>4784</WID>
        <word>الم</word>
        <SID>2</SID>
        <Ayeh>1</Ayeh>
        <Joze>1</Joze>
        <Hezb>1</Hezb>
        <ParentID>3567</ParentID>
        <Page>2</Page>
        <Joint>2</Joint>
        <SName>بقره</SName>
    </row>
    <row>
        <WID>5105</WID>
        <word>ذَلِكَ</word>
        <SID>2</SID>
        <Ayeh>2</Ayeh>
        <Joze>1</Joze>
        <Hezb>1</Hezb>
        <ParentID>7234</ParentID>
        <Page>2</Page>
        <Joint>2</Joint>
        <SName>بقره</SName>
    </row>
    <quran>



I need insert the <sname> before tags <ayeh> that is <ayeh>0 . i write a jquery code but i dont know how i use xslt in jquery ?(below code Dont work)

XML
$('.quranText .ayaNumber').each(function(){
    if($.trim($(this).text())=='﴿0﴾')
       $(this).closest('.aya').prepend('<div class="suraHeaderFrame">'
                    +'<div class="suraHeaderText">'+

                                        <xsl:for-each-group select="//row[./Page/text()=$page]" group-by="Page">
                                            <xsl:for-each-group select="current-group()" group-by="SID">
                                                <xsl:for-each-group select="current-group()" group-by="concat(Page,SID)">
                                                <xsl:choose >
                                                     <xsl:when test = "./Ayeh = 1 or ./Ayeh = 0" >
                                                    <xsl:value-of select="SName"/>
                                                        </xsl:when>
                                                  </xsl:choose>
                                                </xsl:for-each-group>
                                            </xsl:for-each-group>
                                        </xsl:for-each-group>

 +'</div>'
                +'</div>');
});


I should say that often in a one page is alot of <ayeh>0. I am writing a site same this : http://tanzil.net/#109:1 .
Posted

1 solution

XML
$('.quranText .ayaNumber').each(function(){
    var sname = $(this).siblings('.ayaText').attr("SName");
    if($.trim($(this).text())=='﴿0﴾')
       $(this).closest('.aya').prepend('<div class="suraHeaderFrame">'
                        +'<div class="suraHeaderText">'
                                                    +sname
                         +'</div>'
                            +'</div>');
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900