Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 1st, 2006, 04:44 AM
Friend of Wrox
 
Join Date: May 2005
Location: Nürnberg/München, , Germany.
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default Loop in XSL

Hello all,

I am stuck in another problem in my code. I want to loop iteratively in my xml elements but <xsl for each> doesn't help me. I have two situations:

1) I have written
           <xsl:for-each select="fcs:leadParagraph">
        <p><strong><xsl:value-of select="fcs:paragraph"/></strong></p>
        </xsl:for-each>

Which brings the paragraphs

"It is still far too early to sound the death knell, but for many small liberal arts colleges, the SAT may have outlived its usefulness. Since Bowdoin and Bates dropped their testing requirements decades ago, more than a fourth of U.S. News & World Report's Top 100 liberal arts colleges have made admissions exams optional, and new ones are joining the list at a quickening pace.
"
instead of

"It is still far too early to sound the death knell, but for many small liberal arts colleges, the SAT may have outlived its usefulness.

Since Bowdoin and Bates dropped their testing requirements decades ago, more than a fourth of U.S. News & World Report's Top 100 liberal arts colleges have made admissions exams optional, and new ones are joining the list at a quickening pace. "

2) I have headlines which are in an array and each has to refer to a javascript function according to their array index (from 0 till length-1)

  <xsl:for-each select="fcs:folderHeadline">
   <xsl:variable name="headline" select="fcs:headline/fcs:paragraph"/>
                    <xsl:variable name="cut" select="substring($headline,0,50)"/>
                    <td class="text"><h3><a href=""><xsl:value-of select="$cut"/><xsl:text>...</xsl:text></a></h3></td>
  </xsl:for-each>

I want to link the headlines into a kind of JavaScript function like sendData(i)but I couldn't manage to do it. Can anyone help me (just tell me what to do I don't want to make you busy to write the complete code)



Your attitude determines your altitude
__________________
Your attitude determines your altitude
Reply With Quote
  #2 (permalink)  
Old September 1st, 2006, 04:59 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I really can't understand what you need. can you show your XML input and a sample of your required output?

As an aside xsl:for-each doesn't loop through a list of nodes. From a logical point of view it processes each node in the sequence returned by the select simultaneously.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old September 1st, 2006, 05:06 AM
Friend of Wrox
 
Join Date: May 2005
Location: Nürnberg/München, , Germany.
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hallo Joe, I have just sent you an email. Thanks for your help.

Your attitude determines your altitude
Reply With Quote
  #4 (permalink)  
Old September 1st, 2006, 06:47 AM
Friend of Wrox
 
Join Date: May 2005
Location: Nürnberg/München, , Germany.
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually I need an urgent help for the 1st question now. What I did in my AJAX application was

var lead = xmldoc.selectNodes("//fcs:GetArticleResponse/fcs:articleResponse/fcs:articleResultSet/fcs:article/fcs:leadParagraph/fcs:paragraph");
        if(lead==null){
            alert("document is not available");
            }
        else{
        var size = lead.length;

        var paragraph = new Array(size);
        if(size>0){
            for (var i=0; i<size; i++){
                  paragraph[i] = xmldoc.selectNodes("//fcs:GetArticleResponse/fcs:articleResponse/fcs:articleResultSet/fcs:article/fcs:leadParagraph/fcs:paragraph")[i];
                      tmp.write("<p><strong>"+paragraph[i].text+"</strong></p>");
            }//end for
        }//end if
        }

So I could obtain the paragraphs in seperate <p> tags here as
"It is still far too early to sound the death knell, but for many small liberal arts colleges, the SAT may have outlived its usefulness.

Since Bowdoin and Bates dropped their testing requirements decades ago, more than a fourth of U.S. News & World Report's Top 100 liberal arts colleges have made admissions exams optional, and new ones are joining the list at a quickening pace. "

But now what I have written in XSL is

        <xsl:for-each select="fcs:leadParagraph">
        <p><strong><xsl:value-of select="fcs:paragraph"/></strong></p>
        </xsl:for-each>

And I am seeing the all paragraphs in just one <p> tag like:

"It is still far too early to sound the death knell, but for many small liberal arts colleges, the SAT may have outlived its usefulness. Since Bowdoin and Bates dropped their testing requirements decades ago, more than a fourth of U.S. News & World Report's Top 100 liberal arts colleges have made admissions exams optional, and new ones are joining the list at a quickening pace.
"
 What am I doing wrong? How can I write the same situation in my XSL like

for(i=0; i<paragraph.length; i++){
}
??

Your attitude determines your altitude
Reply With Quote
  #5 (permalink)  
Old September 1st, 2006, 06:52 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Without seeing your source XML, it's impossible to tell what you have done wrong.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #6 (permalink)  
Old September 1st, 2006, 06:55 AM
Friend of Wrox
 
Join Date: May 2005
Location: Nürnberg/München, , Germany.
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is my source XML Michael. Sorry it is a bit too long:

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
    <GetArticleResponse xmlns="urn:factiva:developer:v3_0:parsers">
        <articleResponse>
            <articleResultSet count="1">
                <article>
                    <reference>distdoc:archive/ArchiveDoc::Article/NYTF000020060831e28v0004s</reference>
                    <accessionNo>NYTF000020060831e28v0004s</accessionNo>
                    <baseLanguage>en</baseLanguage>
                    <byline>By TAMAR LEWIN </byline>
                    <copyright>(c) 2006 New York Times Company </copyright>
                    <edition>Late Edition - Final</edition>
                    <headline>
                        <paragraph lang="en">Students' Paths To Small Colleges Can Bypass SAT </paragraph>
                    </headline>
                    <leadParagraph>
                        <paragraph>It is still far too early to sound the death knell, but for many small liberal arts colleges, the SAT may have outlived its usefulness. </paragraph>
                        <paragraph>Since Bowdoin and Bates dropped their testing requirements decades ago, more than a fourth of U.S. News &amp; World Report's Top 100 liberal arts colleges have made admissions exams optional, and new ones are joining the list at a quickening pace. </paragraph>
                    </leadParagraph>
                    <pages>
                        <page>1</page>
                    </pages>
                    <publicationDate>2006-08-31</publicationDate>
                    <sectionName>National Desk; SECTA</sectionName>
                    <sourceName>The New York Times</sourceName>
                    <tailParagraphs>
                        <paragraph>The new colleges include Mount Holyoke, Middlebury, Hamilton, Union and Dickinson. In recent months, George Mason, Providence College and Hobart and William Smith Colleges have also become test-optional. </paragraph>
                        <paragraph>Admissions officers said eliminating the testing requirement had increased both the size and diversity of their applicant pools, and bolstered their reputation as places personal enough to consider each applicant individually. </paragraph>
                        <paragraph>At the same time, the revamped, longer SAT, the drop in average scores announced Tuesday and recent problems with scoring have created growing disenchantment. College officials also say that tests -- whether the SAT, or in the Midwest, the ACT -- are not the best predictors of performance. </paragraph>
                        <paragraph>''Test scores are a much weaker predictor of how students will do in college than their high school transcript,'' said Mark Gearan, the president of Hobart and William Smith. ''We really know our applicants, because we have an admissions staff that can read every essay, have a personal interview and review the high school transcript in depth.'' </paragraph>
                        <paragraph>Half a century ago, the SAT was a tool for opening college access to students who did not come from elite schools, a steppingstone to academic meritocracy. But many admissions officers now see the test as a barrier to low-income students and those who do not speak English at home. </paragraph>
                        <paragraph>Test scores, college officials say, present a skewed picture both of poor students who have had little formal preparation, and wealthy ones who spend thousands of dollars -- not to mention evenings, weekends and summers -- on tutoring. </paragraph>
                        <paragraph>''We felt the system had gotten out of whack,'' said Steve Syverson, dean of admissions at Lawrence University, which admitted its first test-optional freshmen this year. ''Back when kids just got a good night's sleep and took the SAT, it was a leveler that helped you find the diamond in the rough. Now that most of the great scores are affluent kids with lots of preparation, it just increases the gap between the haves and the have-nots.'' </paragraph>
                        <paragraph>Test-optional admissions also allow colleges to admit interesting students with low scores, without pulling down rankings by U.S. News &amp; World Report and others who use SAT scores to rate colleges. In fact, test-optional admissions may raise rankings because low scores are unlikely to be submitted. </paragraph>
                        <paragraph>More than 700 colleges and universities are test-optional, but most accept nearly all their applicants. For now, the SAT and ACT remain a rite of passage for students applying to colleges that are more selective in their admissions. There is also no evidence that guidance counselors are advising students to skip testing, and most applicants still submit scores to test-optional colleges. </paragraph><paragraph>But that could change. </paragraph>
                        <paragraph>''We are now at a point where, if you're interested in a liberal arts education at the best schools in the country, you can put together a good portfolio of colleges to apply to and not take the test,'' said Robert Schaeffer, the public education director of FairTest, a group critical of standardized testing. </paragraph>
                        <paragraph>The College Board, which administers the SAT, sees the trend as wrong-headed, but no real threat. ''Even if half of the best small schools in America go test-optional,'' said Gaston Caperton, president of the College Board, ''it's a minimal number of students.'' </paragraph>
                        <paragraph>Of the nation's 17 million college students, fewer than 250,000 attend the top 100 liberal arts colleges. </paragraph>
                        <paragraph>''At a time when the United States is vying internationally for excellence,'' Mr. Caperton said, ''it's very contrary to any decision-making process, in business or education, not to use the data that's available. If I were a parent, applying to a selective school, I would prefer them to use all the data they possibly can.'' </paragraph>
                        <paragraph>But many families visiting test-optional colleges have a different preference. ''I think SAT-optional is great, it's wonderful,'' said Lynne Brandes, of Hanover, Mass., who took her daughter, Jacqueline, on a New England college tour this summer. ''Some families have the money to pay for tutoring, but some don't. I'd love to see the SAT's abolished.'' </paragraph>
                        <paragraph>At test-optional colleges, admissions officers say they look forward to students' liberation from testing. </paragraph>
                        <paragraph>''We hope that now that there are more test-optional schools, students will think about not taking it, and putting their time and money into other activities, like music or writing or community service,'' said Jane B. Brown, vice president for enrollment at Mount Holyoke, which dropped the SAT requirement in 2001. ''We hope they will have more interesting lives.'' </paragraph>
                        <paragraph>But most admissions officials at selective colleges continue to rely on standardized test scores. ''They're especially useful for evaluating the rural Midwestern kid who's No. 1 in a graduating class of nine at a high school you don't know,'' said Paul Thiboutot, dean of admissions at Carleton College. </paragraph>
                        <paragraph>William Shain, the dean of admissions at Bowdoin, has seen the pros and cons. Last year, he was at Vanderbilt, where tests are required. At Bowdoin, the first and most selective college to become test-optional -- admitting fewer than a quarter of its applicants -- Mr. Shain is mindful that each student admitted without scores displaces one with stellar scores and grades. He also said test scores become more helpful as high school transcripts provide fewer clear indicators of students' abilities. </paragraph>
                        <paragraph>''Many schools won't do rankings, there's enormous grade inflation, and parents help write some of the essays,'' he said. ''It's not so easy to disentangle from SAT's. Even the bond-rating people, when a college borrows money, look at SAT scores.'' </paragraph>
                        <paragraph>True, neither the Ivy League nor most large universities are about to drop their testing requirements. At the Ivies, anything that helps differentiate among hordes of highly qualified applicants is useful. And many large public universities do admissions by the numbers. But some state universities have minimized their use of SAT scores. For example, Texas students in the top 10 percent of their high school classes are automatically admitted to the University of Texas or Texas A&amp;M. </paragraph>
                        <paragraph>Growth in test-optional admissions would be bad news for test-preparation companies like Kaplan, which this month issued a news release playing down the trend and warning that students who plan to apply only to test-optional colleges are ''limiting their options.'' </paragraph>
                        <paragraph>Admissions requirements vary widely, even among test-optional colleges. Middlebury, for example, is not entirely test-optional, but it allows students to substitute three subject exams -- Advanced Placement, International Baccalaureate or SAT II's -- for the SAT or ACT. Like several others, it also asks students for a graded high school paper. </paragraph>
                        <paragraph>At Bates College, William Hiss, the vice president for external affairs, said the policy helps attract exceptional students who might not otherwise apply. Lien Le, a Vietnamese refugee with an SAT verbal score of 400, who applied to Bates without submitting her scores, earned a biology degree magna cum laude and then got a medical degree at Brown. </paragraph>
                        <paragraph>''Sure, all the kids who get SAT's over 700 have real academic strengths,'' he said. ''But can you say that all the kids who get under 600 don't, that they won't do well?'' </paragraph>
                        <paragraph>No, according to Bates's 20-year study of test-optional admissions, finding that the graduation rate of those who submitted scores differed by only one-tenth of a percent from that of students who did not, about a third of Bates' students. </paragraph>
                        <paragraph>''Human intelligence and ambition is more complex, more multifaceted, than any standardized testing system can capture,'' Mr. Hiss said. </paragraph>
                        <paragraph>Photo: A sample SAT answer sheet. (Photo by John Nordell/The Christian Science Monitor, via Getty Images)(pg. A22) </paragraph>
                    </tailParagraphs>
                    <wordCount>1366</wordCount>
                    <logo source="http://logos.factiva.com" image="nytfLogo.gif"></logo>
                </article>
            </articleResultSet>
        </articleResponse>
    </GetArticleResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Your attitude determines your altitude
Reply With Quote
  #7 (permalink)  
Old September 1st, 2006, 07:05 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your code looks fine. That means the bug is somewhere in the parts of the application that you haven't shown us.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #8 (permalink)  
Old September 1st, 2006, 07:08 AM
Friend of Wrox
 
Join Date: May 2005
Location: Nürnberg/München, , Germany.
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok here is my XSL

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fcs="urn:factiva:developer:v3_0:parsers" xmlns:msxsl="urn:schemas-microsoft-com:xslt" >
<xsl:output method="html" version="4.0" />
<xsl:template match ="/">
<xsl:apply-templates select="SOAP-ENV:Envelope/SOAP-ENV:Body/fcs:GetArticleResponse/fcs:articleResponse/fcs:articleResultSet/fcs:article"></xsl:apply-templates>
</xsl:template>
<xsl:template match="SOAP-ENV:Envelope/SOAP-ENV:Body/fcs:GetArticleResponse/fcs:articleResponse/fcs:articleResultSet/fcs:article">
    <head>
            <title>Factiva Test</title>
            <link href='http://intranet1-t.internal.epo.org/portal/themes/html/epoIntranetCD/cssTheme.css' rel="stylesheet" type="text/css" />
            <link href='http://intranet1-t.internal.epo.org/portal/themes/html/epoIntranetCD/cssPageBody.css' rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div id="epoContentStandard">
        <img src="http://dg1-2.internal.epo.org/_test/Huerol/Factiva/flogostyle1.gif" align="right" />
        <br clear="all"/>
        <h1 style="margin-bottom:0.3ex;"><xsl:value-of select="fcs:headline/fcs:paragraph"/></h1>
        <p style="margin-bottom:3.5ex;font-size:80%;color:#888888;"><xsl:value-of select="fcs:copyright"/></p>
        <xsl:for-each select="fcs:leadParagraph">
        <p><strong><xsl:value-of select="fcs:paragraph"/></strong></p>
        </xsl:for-each>
        </div>
    </body>
</xsl:template>
</xsl:stylesheet>
I didn't understand what I am doing wrong here in the last for-each situation. It doesn't write the paragraphs into the seperate <p> tags

Your attitude determines your altitude
Reply With Quote
  #9 (permalink)  
Old September 1st, 2006, 07:10 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

This stylesheet does some of what you want. I'm not sure why you want a for-each, can there be more than one leadParagraph?
Code:
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fcs="urn:factiva:developer:v3_0:parsers">

  <xsl:template match="/">
    <html>
      <body>
        <xsl:apply-templates select="//fcs:leadParagraph"/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="fcs:leadParagraph">
    <div style="border: 3px inset #c0c0c0">
      <xsl:apply-templates select="fcs:paragraph"/>
    </div>
  </xsl:template>

  <xsl:template match="fcs:paragraph">
    <p>
      <b>
        <xsl:value-of select="."/>
      </b>
    </p>
  </xsl:template>
</xsl:stylesheet>
--

Joe (Microsoft MVP - XML)
Reply With Quote
  #10 (permalink)  
Old September 1st, 2006, 07:22 AM
Friend of Wrox
 
Join Date: May 2005
Location: Nürnberg/München, , Germany.
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

leadParagraph is optional there can be 0 or 1 leadparagraphs and thanks very much for your help it worked. Please check your mail account ;) (For my second question above) Can anyone briefly tell me how can I do an iterative loop in XSL?

My 2nd problems is that I need an iterative loop. That means I have another XML source which has the headlines and when I click onto a headline, a pop up window is opened to see the article of that headline. Normally I could have done it via



          do{
            myTable = myTest.appendChild(document.createElement("table") );
               myTable.style.borderBottom = "none";
               myTable.setAttribute("id","epoNewsItem");


            article1[i] = xmldoc.selectNodes("//fcs:folder/fcs:folderHeadlinesResultSet/fcs:folderHeadline/fcs:contentParts/fcs:part/@reference")[i].value;
            myRow = myTable.insertRow(0);
            //myArray1[i] = xmldoc.selectNodes("//fcs:folder/fcs:folderHeadlinesResultSet/fcs:folderHeadline/fcs:baseLanguage")[i];
            //myArray2[i] = xmldoc.selectNodes("//fcs:folder/fcs:folderHeadlinesResultSet/fcs:folderHeadline/fcs:wordCount")[i];
            myArray3[i] = xmldoc.selectNodes("//fcs:folder/fcs:folderHeadlinesResultSet/fcs:folderHeadline/fcs:publicationDate")[i];
            var dateText = myArray3[i].text;
            var year = dateText.substring(0,4);
            var month = dateText.substring(5,7);
            var day = dateText.substring(8,10);
            //myArray4[i] = xmldoc.selectNodes("//fcs:folder/fcs:folderHeadlinesResultSet/fcs:folderHeadline/fcs:publicationTime")[i];
            myArray6[i] = xmldoc.selectNodes("//fcs:folder/fcs:folderHeadlinesResultSet/fcs:folderHeadline/fcs:contentParts/@contentType")[i];
            if(myArray6[i].value == "WebPage"){
                icon = "http://dg1-2.internal.epo.org/_test/Huerol/Factiva/fwebicon.gif";
                alt = "Factiva Web Content Icon";
                }
            else {
                icon = "http://dg1-2.internal.epo.org/_test/Huerol/Factiva/fac_pub.gif";
                alt = "Factiva Publications Icon";
                }
            myCell1 = myRow.insertCell(0);
            myCell1.className = "text";
            myCell1.innerHTML = "<img src='"+icon+"' alt ='"+alt+"' align='left' style='margin-top:3px' />&nbsp;"+day+"."+month+"."+year;
            myCell1.innerHTML += "<br clear='all' />";
            myArray5[i] = xmldoc.selectNodes("//fcs:folder/fcs:folderHeadlinesResultSet/fcs:folderHeadline/fcs:headline/fcs:paragraph")[i];

            str[i] = myArray5[i].text;
            header[i] = str[i].substring(0,50);
            //myCell1.innerHTML += "<h3>" + myArray5[i].text + "</h3> <p><a href = javascript:sendContentRequest("+i+") class='more'>more...</a></p>";
             myCell1.innerHTML += "<h3><a href = javascript:sendContentRequest("+i+") class='more'>" + header[i] + "...</a></h3>";
            myArray7[i] = xmldoc.selectNodes("//fcs:folder/fcs:folderHeadlinesResultSet/fcs:folderHeadline/fcs:snippet")[i];
            if(myArray7[i]==null){
                return false;
                }
            else{
                var cPos = myArray7[i].text.indexOf("-- ");
                if (cPos >= 0)
                    snippet[i] = myArray7[i].text.substring(cPos + 3,100 + cPos + 3);
                else
                    snippet[i] = myArray7[i].text.substring(0,100);
                myCell1.innerHTML += "<p>"+snippet[i]+"...</p>";
                }
            myTest.appendChild(myTable);
        i++;
          } while(i<size)

What I should do in my other XSL to reference the links to a javascript function which takes the i th headline to send it to the i th article XSL data. What I have written in XSL was

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fcs="urn:factiva:developer:v3_0:parsers" xmlns:msxsl="urn:schemas-microsoft-com:xslt" >
<xsl:output method="html" version="4.0" />
<xsl:template match ="/">
<xsl:apply-templates select="SOAP-ENV:Envelope/SOAP-ENV:Body/fcs:GetFolderHeadlinesResponse/fcs:folderHeadlinesResponse/fcs:folderHeadlinesResult/fcs:folder/fcs:folderHeadlinesResultSet"></xsl:apply-templates>
</xsl:template>
<xsl:template match="SOAP-ENV:Envelope/SOAP-ENV:Body/fcs:GetFolderHeadlinesResponse/fcs:folderHeadlinesResponse/fcs:folderHeadlinesResult/fcs:folder/fcs:folderHeadlinesResultSet">
    <head>
            <title>Factiva Test</title>
            <link href='http://intranet1-t.internal.epo.org/portal/themes/html/epoIntranetCD/cssTheme.css' rel="stylesheet" type="text/css" />
            <link href='http://intranet1-t.internal.epo.org/portal/themes/html/epoIntranetCD/cssPageBody.css' rel="stylesheet" type="text/css" />
    </head>
    <body>
        <img src="http://dg1-2.internal.epo.org/_test/Huerol/Factiva/fac1.bmp" align="right" />
        <br clear="all"/>
        <table id="epoNewsItem" style="border-bottom:none">
                <xsl:for-each select="fcs:folderHeadline">
                <xsl:variable name="content" select="fcs:contentParts/@contentType"/>

                <xsl:variable name="year" select="substring(fcs:publicationDate,0,5)"/>
                <xsl:variable name="month" select="substring(fcs:publicationDate,6,2)"/>
                <xsl:variable name="day" select="substring(fcs:publicationDate,9,2)"/>
                <tr>
                     <xsl:choose>
                                        <xsl:when test="$content='WebPage'">
                                            <td class="text"><img src="http://dg1-2.internal.epo.org/_test/Huerol/Factiva/fwebicon.gif" alt="Factiva Web Content Icon" style='margin-top:3px'/><xsl:text></xsl:text><xsl:value-of select="$day"/>.<xsl:value-of select="$month"/>.<xsl:value-of select="$year"/></td>
                                        </xsl:when>
                                        <xsl:otherwise>
                    <td class="text"><img src="http://dg1-2.internal.epo.org/_test/Huerol/Factiva/fac_pub.gif" alt="Factiva Publications Icon" style='margin-top:3px'/><xsl:text></xsl:text><xsl:value-of select="$day"/>.<xsl:value-of select="$month"/>.<xsl:value-of select="$year"/></td>
                    </xsl:otherwise>
                                    </xsl:choose>
                  </tr>
                  <tr>
                    <xsl:variable name="headline" select="fcs:headline/fcs:paragraph"/>
                    <xsl:variable name="cut" select="substring($headline,0,50)"/>
                    <td class="text"><h3><a href=""><xsl:value-of select="$cut"/><xsl:text>...</xsl:text></a></h3></td>
                  </tr>
                  <tr>
                     <xsl:variable name="snippet" select="fcs:snippet"/>
                     <xsl:variable name="cPos" select="index-of($snippet, '-')"/>
                    <xsl:choose>
                        <xsl:when test="$cPos >= 0">
                            <xsl:variable name="cutSnippet" select="substring($snippet,$cPos+3,100+$cPos+3)"/>
                            <td class="text"><xsl:value-of select="$cutSnippet"/></td>
                        </xsl:when>
                        <xsl:otherwise>
                         <xsl:variable name="cutSnippet" select="substring($snippet,0,100)"/>
                          <td class="text"><xsl:value-of select="$cutSnippet"/></td>
                        </xsl:otherwise>
                    </xsl:choose>

                 </tr>
                </xsl:for-each>
        </table>
        </body>
    </xsl:template>
</xsl:stylesheet>

Its XML file is

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<GetFolderHeadlinesResponse xmlns="urn:factiva:developer:v3_0:parsers">
    <folderHeadlinesResponse>
        <folderHeadlinesResult>
            <folder>
                <folderName>GroupFolder</folderName>
                <folderID>100085070</folderID>
                <highlightString>T|test T|article N|fmt O|c T|report N|fmt O|c O|, T|file N|fmt O|c O|, T|webpage N|fmt O|c O|, O|+ T|en N|la O|c O|+</highlightString>
                <bookmark>20060831040744.124+20060831040744.124+ 5</bookmark>
                <contact>mike.moreno@factiva.com</contact>
                <editorPostMethod>Automatic</editorPostMethod>
                <queryHitCount>172</queryHitCount>
                <moreHeadlines>true</moreHeadlines>
                <folderHeadlinesResultSet count="5">
                    <folderHeadline>
                        <baseLanguage>en</baseLanguage>
                        <ipDocumentID>20060831782688</ipDocumentID>
                        <accessionNo>NYTF000020060831e28v0004s</accessionNo>
                        <wordCount>1366</wordCount>
                        <publicationDate>2006-08-31</publicationDate>
                        <sourceCode>nytf</sourceCode>
                        <sourceName>The New York Times</sourceName>
                        <sectionName>National Desk; SECTA</sectionName>
                        <headline>
                            <paragraph lang="en">Students' Paths To Small Colleges Can Bypass SAT </paragraph>
                        </headline>
                        <snippet>
                            <paragraph>It is still far too early to sound the death knell, but for many small liberal arts colleges, the SAT may have outlived its usefulness. </paragraph><paragraph>Since Bowdoin and Bates dropped their testing requirements decades ago, more than a fourth of U.S. News ...</paragraph>
                        </snippet>
                        <byline>By TAMAR LEWIN </byline>
                        <copyright>(c) 2006 New York Times Company </copyright>
                        <contentParts contentType="Article" primaryReference="distdoc:archive/ArchiveDoc::Article/NYTF000020060831e28v0004s">
                            <part type="NewsArticle" size="9233" reference="distdoc:archive/ArchiveDoc::Article/NYTF000020060831e28v0004s"></part>
                        </contentParts>
                        <editor>
                            <contentID>45665568</contentID>
                            <priority>None</priority>
                        </editor>
                    </folderHeadline>
                    <folderHeadline>
                        <baseLanguage>en</baseLanguage>
                        <ipDocumentID>BLDW000020060831e28v0000z</ipDocumentID>
                        <accessionNo>BLDW000020060831e28v0000z</accessionNo>
                        <wordCount>429</wordCount>
                        <publicationDate>2006-08-31</publicationDate>
                        <sourceCode>bldw</sourceCode>
                        <sourceName>Blood Weekly</sourceName>
                        <headline>
                            <paragraph lang="en">HIV/AIDS Anemia; Direct antiglobulin-positive results may be related to lower hemoglobin levels in HIV/AIDS </paragraph>
                        </headline>
                        <snippet>
                            <paragraph>2006 AUG 31 - (NewsRx.com) -- Direct antiglobulin-positive results may be related to lower hemoglobin levels in HIV-infected patients. </paragraph>
                            <paragraph>"There are conflicting opinions regarding the effect of positive direct antiglobulin test (DAT) on ...</paragraph>
                        </snippet>
                        <copyright>(c) Copyright 2006 Blood Weekly via NewsRx.com </copyright>
                        <contentParts contentType="Article" primaryReference="distdoc:archive/ArchiveDoc::Article/BLDW000020060831e28v0000z">
                            <part type="NewsArticle" size="3423" reference="distdoc:archive/ArchiveDoc::Article/BLDW000020060831e28v0000z"></part>
                        </contentParts>
                        <editor>
                            <contentID>45665106</contentID>
                            <priority>None</priority>
                        </editor>
                    </folderHeadline>
                    <folderHeadline>
                        <baseLanguage>en</baseLanguage>
                        <ipDocumentID>20060831780375</ipDocumentID>
                        <accessionNo>NYTF000020060831e28v0002b</accessionNo>
                        <wordCount>445</wordCount>
                        <publicationDate>2006-08-31</publicationDate>
                        <sourceCode>nytf</sourceCode>
                        <sourceName>The New York Times</sourceName>
                        <sectionName>Editorial Desk; SECTA</sectionName>
                        <headline>
                            <paragraph lang="en">Raising Nicotine Doses, on the Sly </paragraph>
                        </headline>
                        <snippet>
                            <paragraph>While most of us thought the country was trying to curb smoking, and the rapacious habits of the tobacco companies, it turns out the industry has been sneakily making cigarettes more addictive. </paragraph>
                        </snippet>
                        <copyright>(c) 2006 New York Times Company </copyright>
                        <contentParts contentType="Article" primaryReference="distdoc:archive/ArchiveDoc::Article/NYTF000020060831e28v0002b">
                            <part type="NewsArticle" size="3450" reference="distdoc:archive/ArchiveDoc::Article/NYTF000020060831e28v0002b"></part>
                        </contentParts>
                        <editor>
                            <contentID>45664981</contentID>
                            <priority>None</priority>
                        </editor>
                    </folderHeadline>
                    <folderHeadline>
                        <baseLanguage>en</baseLanguage>
                        <ipDocumentID>20060831780367</ipDocumentID>
                        <accessionNo>NYTF000020060831e28v0002a</accessionNo>
                        <wordCount>499</wordCount>
                        <publicationDate>2006-08-31</publicationDate>
                        <sourceCode>nytf</sourceCode>
                        <sourceName>The New York Times</sourceName>
                        <sectionName>Editorial Desk; SECTA</sectionName>
                        <headline>
                            <paragraph lang="en">Stars in Their Eyes </paragraph>
                        </headline>
                        <snippet>
                            <paragraph>In a rare moment of candor this week, Defense Secretary Donald Rumsfeld acknowledged that he's not sure if the United States missile defense system is ready to work. When asked if the shield could protect the United States from a North ...</paragraph>
                        </snippet>
                        <copyright>(c) 2006 New York Times Company </copyright>
                        <contentParts contentType="Article" primaryReference="distdoc:archive/ArchiveDoc::Article/NYTF000020060831e28v0002a">
                            <part type="NewsArticle" size="3540" reference="distdoc:archive/ArchiveDoc::Article/NYTF000020060831e28v0002a"></part>
                        </contentParts>
                        <editor>
                            <contentID>45664980</contentID>
                            <priority>None</priority>
                        </editor>
                    </folderHeadline>
                    <folderHeadline>
                        <baseLanguage>en</baseLanguage>
                        <ipDocumentID>BLDW000020060831e28v0000g</ipDocumentID>
                        <accessionNo>BLDW000020060831e28v0000g</accessionNo>
                        <wordCount>222</wordCount>
                        <publicationDate>2006-08-31</publicationDate>
                        <sourceCode>bldw</sourceCode>
                        <sourceName>Blood Weekly</sourceName>
                        <headline>
                            <paragraph lang="en">Business Update; Hema-Quebec selects IDM Surround as its laboratory management system </paragraph>
                        </headline>
                        <snippet>
                            <paragraph>2006 AUG 31 - (NewsRx.com) -- Information Data Management, Inc., (IDM) announced that Hema-Quebec has selected IDM's Surround 4.2.1 System as their new centralized data collection and laboratory management system. </paragraph>
                        </snippet>
                        <copyright>(c) Copyright 2006 Blood Weekly via NewsRx.com </copyright>
                        <contentParts contentType="Article" primaryReference="distdoc:archive/ArchiveDoc::Article/BLDW000020060831e28v0000g">
                            <part type="NewsArticle" size="2091" reference="distdoc:archive/ArchiveDoc::Article/BLDW000020060831e28v0000g"></part>
                        </contentParts>
                        <editor>
                            <contentID>45665004</contentID>
                            <priority>None</priority>
                        </editor>
                    </folderHeadline>
                </folderHeadlinesResultSet>
            </folder>
        </folderHeadlinesResult>
    </folderHeadlinesResponse>
</GetFolderHeadlinesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

(Sorry for the long codes but you couldn't understand what I meant when I didn't include these codes.

I couldn't reference the a hrefs in my XSL because I don't know how I can use an iterative loop in XSL.




Your attitude determines your altitude
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to loop through a HashMap in XSL? sunilnk XSLT 6 April 10th, 2017 04:09 AM
help: how can I break from xsl for-each loop ? back2grave XSLT 5 May 31st, 2012 12:03 PM
XSL Loop and incrementing a variable 2007-03-29 XSLT 8 March 30th, 2007 10:41 AM
xsl:for-each loop Tomi XSLT 3 September 7th, 2006 05:35 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM



All times are GMT -4. The time now is 12:28 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.