Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 June 5th, 2006, 05:57 PM
Registered User
 
Join Date: Jun 2006
Location: Menlo Park, CA, USA.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default loop in xslt


I am new in xslt coding, and I need to loop in the following code three times, and add a linefeed at the end. I would appreciate your help on this:




        <xsl:choose>
            <xsl:when test="name[@type='other']">
                <xsl:apply-templates select="name[@type='other']"/>
                <xsl:text>|#10;</xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>|#10;</xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

Thx,
Victoria

Reply With Quote
  #2 (permalink)  
Old June 6th, 2006, 02:18 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

Your comment "add all three nickname fields" suggests you are actually looping over some nodes in your source document. So we need to see what your source document looks like.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old June 6th, 2006, 11:54 AM
Registered User
 
Join Date: Jun 2006
Location: Menlo Park, CA, USA.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Here is the command which runs for this process. can I find the source document location from any of these property files:

JSDK_BIN/java -Dlog4j.configuration=amcom_harvester.properties -classpath $CLASSPATH edu.stanford.harvester.Harvester $PROPERTIES_D
IR/amcom_harvester.properties $PROPERTIES_DIR/load_amcom_processor.properties $1

Reply With Quote
  #4 (permalink)  
Old June 6th, 2006, 12:02 PM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

The program you are running is called edu.stanford.harvester.Harvester. I have absolutely no idea what this program does or what it expects to find in its property files.

Are you trying to tell me that you are programming in XSLT without knowing what your XML input document looks like?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #5 (permalink)  
Old June 6th, 2006, 06:36 PM
Registered User
 
Join Date: Jun 2006
Location: Menlo Park, CA, USA.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default


I guess that is correct. I assumed that I can just look at other xslt and copy the loop procedure.

I am just trying to learn xslt, and the original programmer has left. I thought this would be a good opportunity for me to learn this....

My code already display the 1st Nick name, I just know that I should check for that field three times....

Thx,
Victoria

Reply With Quote
  #6 (permalink)  
Old June 7th, 2006, 02:28 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 Posts
Default

I wouldn't touch the XSLT code without knowing exactly what its input looks like. You can find out using

<xsl:message>
  <xsl:copy-of select="."/>
</xsl:message>

right in the initial template (assuming the xsl:message output is going somewhere you can find it).

It's not really enough to see one source document. You need to see a specification describing the set of all possible source documents. But that may be hoping for too much.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #7 (permalink)  
Old June 7th, 2006, 04:46 PM
Registered User
 
Join Date: Jun 2006
Location: Menlo Park, CA, USA.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Ok, maybe this will help. Here is what I have to show the Nick Name, and the name field includes 0 to 3 NickNickNick, I need to parse it to ||| or Nick|Nick|Nick| or Nick|| or Nick|Nick||

        <xsl:choose>
            <xsl:when test="name[@type='other']">
                <xsl:apply-templates select="name[@type='other']"/>
                <xsl:text>|</xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>|</xsl:text>
                <xsl:text>|</xsl:text>
                <xsl:text>|</xsl:text>
            </xsl:otherwise>
             <xsl:text>#10;</xsl:text>
        </xsl:choose>


And, here is the output:

99999999|U|R|lastnm, firstnm middle|GQZE|Department of XXXXX Management|Director|||||||123 fun Street, Second Floor|EMP|6114|
00-000-000-0000||00-000-000-0000||99999999|email@email.edu|M|||||||||||00-000-000-0000|99999999|||||||||||||||||||||99999
999|W|W||S|W|||lastnm, firstnmlastnm, firstnm M.|

What should I change in the code so I see this output:

99999999|U|R|lastnm, firstnm middle|GQZE|Department of XXXXX Management|Director|||||||123 fun Street, Second Floor|EMP|6114|
00-000-000-0000||00-000-000-0000||99999999|email@email.edu|M|||||||||||00-000-000-0000|99999999|||||||||||||||||||||99999
999|W|W||S|W|||lastnm, firstnm|lastnm, firstnm M.||

Thanks for all your help,
Victoria


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
Nested For-Each Loop In XSLT dghosh XSLT 10 July 2nd, 2008 04:34 AM
XSLT Loop? kwilliams XSLT 1 June 16th, 2008 06:04 PM
xslt when loop problem check XSLT 1 April 18th, 2008 08:47 AM
FOR LOOP IN XSLT im_himanshu2004 XSLT 0 October 10th, 2007 02:27 PM
javascript 'for' loop in xslt mummra1 XSLT 22 February 6th, 2007 04:26 PM



All times are GMT -4. The time now is 06:18 AM.


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