Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 19th, 2003, 01:06 PM
Registered User
 
Join Date: Dec 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default hello, some problems with XSL-FO

Hello All, I hope somebody can help me :)

Let me explain the project, I have two xml files (courses_codes.xml and courses.xml)
, I need to read this files and converted them to XSL-FO. The goal is to produce
a PDF file that contains course catalog information for a particular course
group (e.g. AFAM, CSCI, BIOL, etc.) for the 2003-2004 academic year. Also the
XSLT should accept a parameter named "group" that will determine which course group
information will be used (e.g. values for group might be "CSCI", "BIOL", "CHEM", etc).
The XSLT should also accept a parameter named "year".

The XLS-FO first creates a title, using the fullname of the course group selected,
them creates a Table of Contect (TOC) with all the courses, and those courses are
linked to an individual page containing the course information.

The courses in a group has to be unique, and the ones selected using the
global parameters (group, year)

So my questions is how can achive this ??


My XML files are :

courses_codes.xml

<courses_codes>
<course_groups>
<course_group code="AFAM" name="African American Studies"/>
<course_group code="ANTH" name="Anthropology and Archaeology"/>
</course_groups>
</courses_codes>

courses.xml

<dce_courses>
  <course acad_year="2003" term_id="2" crn="21135">
    <course_group>AFAM</course_group>
    <course_num>E-110</course_num>
    <title>Images of Africana People in Cinema</title>
    <meeting>
      <meeting_days>W</meeting_days>
      <meeting_begin>1730</meeting_begin>
      <meeting_end>1930</meeting_end>
      <location>Sever Hall 110</location>
    </meeting>
    <course_head>
      <person>
        <person_name>Pashington Obeng</person_name>
        <person_title>PhD, Visiting Lecturer on World Religions, Harvard Divinity School and Assistant Profess$
      </person>
    </course_head>
    <description>An examination of the sociocultural, political, and economic aspects of Africana people throu$
  </course>
  <course acad_year="2003" term_id="2" crn="22066">
    <course_group>ANTH</course_group>
    <course_num>E-135</course_num>
    <title>The Archaeology of the American Southwest</title>
    <meeting>
      <meeting_days>M</meeting_days>
      <meeting_begin>1730</meeting_begin>
      <meeting_end>1930</meeting_end>
      <location>Harvard Hall 201</location>
    </meeting>
    <course_head>
      <person>
        <person_name>Steven A. LeBlanc</person_name>
        <person_title>PhD, Senior Lecturer on Anthropology, Harvard University</person_title>
      </person>
    </course_head>
    <description>This course considers the prehistory of the American Southwest from PaleoIndian times to Euro$
  </course>
<dce_courses>
:)
Thx for the help!!
Merry X-MAS!!

LuisM

 
Old December 19th, 2003, 01:23 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well none of the actions are particularly difficult but they are time consuming. The stages are:
1) Produce a finished example document with fo markup of your desired output.
2) Write a stylesheet to produce this from your initial two xml files.
3) Decide on which tool to use to get pdf from the result document.

Which of these are you stuck on? XSL-FO is a vast topic and even simple documents can be quite verbose. Once you have your example a stylesheet to get this should be easy.
How to pass parameters to a stylesheet depends on which engine you are using.
Awaiting more info:)

Joe (MVP - xml)
 
Old December 19th, 2003, 02:11 PM
Registered User
 
Join Date: Dec 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello joefawcett and thx for the quick response.

To create the pdf file I'm using cocoon, is the most easy,
I also past the global parameters using the cocoon pipeline.

My problems is more related to the XSLT, becuase I'm cannot
get the unique course tags "<course_group>" from the global parameter
"group".

My problem is creating the apropiate stylesheet that will output a
XSL-FO file, with a title, TOC and the courses information.

Any sugestions ?

thx :)

LuisMM

 
Old December 19th, 2003, 02:31 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

To get the "course_group" element from within the xslt you need the document function. Let's say you are running your stylesheet against course.xml and have passed in your group parameter:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:param name="group">AFAM</xsl:param>
  <xsl:variable name="courseCodes" select="document('courses_codes.xml')"/>
  <xsl:template match="/">
    <xsl:value-of select="$courseCodes/courses_codes/course_groups/course_group[@code = $group]/@name"/>   
  </xsl:template>  
</xsl:stylesheet>
As to the other part if you don't know xsl-fo then you have your work cut out. I will try to have a bash at a basic document tomorrow if I can.



--

Joe
 
Old December 19th, 2003, 02:55 PM
Registered User
 
Join Date: Dec 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey joefawcett you are a life saver :)

The code you gave me, is working like a chain, its given me the full name title :)

I'm not much familiar with XSL-F0, this is my first XSL-F0 stylesheet :)

I'm creating the TOC and the courses information, but I believe I'm doing it wrong, because is not working as it should...

This is my stylesheet (partial code :):

<?xml version="1.0" encoding="utf-8"?>



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:fo="http://www.w3.org/1999/XSL/Format"
 version="1.0">
  <xsl:output method="xml"/>


  <xsl:param name="group" />
  <xsl:param name="year" />


       <fo:block>
        <xsl:for-each select="//course[course_group=$group]">
         <xsl:sort select="title" />
          <fo:block text-align-last="justify">
           <fo:basic-link>
            <xsl:attribute name="internal-destination">
             <xsl:value-of select="generate-id()" />
            </xsl:attribute>
            <xsl:value-of select="title"/>
            <fo:leader leader-pattern="dots" />
            <fo:page-number-citation>
             <xsl:attribute name="ref-id">
              <xsl:value-of select="generate-id()" />
             </xsl:attribute>
            </fo:page-number-citation>
           </fo:basic-link>
          </fo:block>
        </xsl:for-each>
       </fo:block>

    The TOC works more a less :)
   The problem comes when creating each course information, this is
   what i'm doing:


        <xsl:for-each select="//course[course_group=$group]">
         <xsl:sort select="title" />
         <fo:block break-before="page" xsl:use-attribute-sets="pdf-title">
          <xsl:attribute name="id">
           <xsl:value-of select="generate-id()" />
          </xsl:attribute>
         </fo:block>
         <fo:block xsl:use-attribute-sets="page-title">
          <xsl:value-of select="title" />,
          <xsl:value-of select="course_num" />
          (CRN:<xsl:value-of select="@crn" />)
         </fo:block>
         <fo:block xsl:use-attribute-sets="normal">
          Meeting Information:
          <fo:block>
           Days: <xsl:value-of select="./metting/meeting_days" />
          </fo:block>
          <fo:block>
           Begin: <xsl:value-of select="/metting/meeting_begin" />
          </fo:block>
          <fo:block>
           End: <xsl:value-of select="/metting/meeting_end" />
          </fo:block>
          <fo:block>
           Location: <xsl:value-of select="/metting/location" />
          </fo:block>
          <fo:block>
           Professor: <xsl:value-of select="person_name" />
       </fo:block>
          <fo:block>
           Title: <xsl:value-of select="person_name" />
          </fo:block>
          <fo:block>
           Course Description: <xsl:value-of select="description" />
          </fo:block>
         </fo:block>
        </xsl:for-each>

How can I select those course using the group and year parameters, have to be unique!

Comments :)

thx a lot!!!!
Happy X-MAS!!

LuisMM









Similar Threads
Thread Thread Starter Forum Replies Last Post
xHTML to XSL:FO to PDF NotesSensei XSLT 0 September 2nd, 2006 10:02 AM
RDF, OWL and XSL-FO NEO1976 XSLT 6 August 23rd, 2006 04:23 AM
XSL-FO NEO1976 XML 2 July 19th, 2006 10:10 AM
xsl:fo with Select Birger XSLT 4 July 18th, 2006 11:38 AM
XSL-FO Question gray XSLT 1 February 18th, 2005 11:31 AM





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