|
Kia Vang
Mongryong at sympatico.ca
Fri Jan 10 00:57:05 EST 2003
Okay, I'm really frustrated. My code seems very simple, yet I can't get
mod_python to output it correctly.
Here's the mod_python code:
from Ft.Xml import InputSource
from Ft.Xml.Xsl import Processor
from mod_python import apache
def handler(req):
p = Processor.Processor()
trans = InputSource.DefaultFactory.fromUri("request.xsl")
src = InputSource.DefaultFactory.fromUri("request.xml")
p.appendStylesheet(trans)
res = p.run(src, topLevelParams={'error':0} )
req.content_type="text/html"
req.write(res)
return apache.OK
Here's a cgi version:
from Ft.Xml import InputSource
from Ft.Xml.Xsl import Processor
import sys
if __name__ == "__main__":
p = Processor.Processor()
trans = InputSource.DefaultFactory.fromUri("request.xsl")
src = InputSource.DefaultFactory.fromUri("request.xml")
p.appendStylesheet(trans)
sys.write("Content-type: text/html")
p.run(src, topLevelParams={'error':0}, outputStream=sys.stdout )
Now, I've also done some tests with libxml2 and libxslt. I get the same
result with mod_python outputting missing information.
Am I missing something? I'm using the latest versions of apache,
python, and mod_python.
On Wed, 2003-01-08 at 20:15, Gregory Bond wrote:
> > any errors/exceptions are occuring. It seems as if during XSLT
> > processing, the source XML document is being ignored.
>
> See FAQ 3.5 (http://www.modpython.org/FAQ/faqw.py?req=show&file=faq03.005.htp)
> for some hints about what changes between CGI and mod_python. My money is on
> environment variables or PWD.
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.modpython.org/pipermail/mod_python/attachments/20030110/55fe2ec7/request-0003.htm
-------------- next part --------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template name="createObjectiveFormItems">
<ol>
<xsl:for-each select="/resume/objectiveList/objective">
<xsl:variable name="objName">objective<xsl:value-of select="@id"/></xsl:variable>
<li>
<xsl:value-of select="@category"/>
<input type="checkbox">
<xsl:attribute name="value">
<xsl:value-of select="$objName"/>
</xsl:attribute>
</input>
</li>
</xsl:for-each>
</ol>
</xsl:template>
<xsl:template name="createCategoryFormItems">
<ul>
<xsl:for-each select="/resume/categoryList/category">
<div>
<input type="checkbox">
<xsl:attribute name="value">
<xsl:value-of select="@name"/>
</xsl:attribute>
<span>
<xsl:value-of select="@name"/>
</span>
</input>
</div>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template name="createCategoryStyle">
<style type="text/css">
<xsl:for-each select="/resume/categoryList/category">
<xsl:text> .</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>{}</xsl:text>
</xsl:for-each>
</style>
</xsl:template>
<xsl:template name="createOccupationFormItems">
<ul>
<xsl:for-each select="/resume/occupationList/occupation">
<div>
<input type="checkbox">
<xsl:attribute name="value">
<xsl:value-of select="occupationType/@name"/>
</xsl:attribute>
<span>
<xsl:value-of select="occupationType/@name"/>
</span>
</input>
</div>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<title>RezQuest</title>
<link rel="stylesheet" href="/rezquest/css/professional.css" type="text/css" title="professional" media="all"/>
<link rel="stylesheet" href="/rezquest/css/elegant.css" type="text/css" title="elegant" media="all"/>
<link rel="stylesheet" href="/rezquest/css/contemporary.css" type="text/css" title="contemporary" media="all"/>
<script type="text/javascript" src="/rezquest/scripts/common.js"/>
<script type="text/javascript" src="/rezquest/scripts/main.js"/>
<xsl:call-template name="createCategoryStyle"/>
</head>
<body>
<div id="menu">
<div id="appTitle">
<h3>RezQuest 0.1</h3>
</div>
<div id="styleForm" class="menuItem">
<form name="styleForm">
<h3>Select Style</h3>
<div><input type="radio" name="style" value="professional"/>professional</div>
<div><input type="radio" name="style" value="elegant"/>elegant</div>
<div><input type="radio" name="style" value="contemporary"/>contemporary</div>
<div><input id="refreshButton" type="button" name="refresh" value="Refresh"/></div>
</form>
</div>
<div id="fontForm" class="menuItem">
<form name="fontForm" onSubmit="window.focus(); return false;">
<h3>Adjust Base Font-Size</h3>
<div><input type="radio" name="fontSizeType" value="%" checked="true"/>percent(%)</div>
<div><input type="radio" name="fontSizeType" value="em"/>M-height(em)</div>
<div><input type="radio" name="fontSizeType" value="ex"/>x-height(ex)</div>
<div>
<input id="fontSizeVal" type="text" name="fontSizeVal" value="100" size="4" maxLength="3" onkeypress="return resume_fontSizeOnKeyDown(event);"/>
<input id="fontSizeApply" type="button" name="fontSizeApply" value="Apply"/>
</div>
</form>
</div>
<div id="sectionForm" class="menuItem">
<form name="sectionForm">
<h3>Select Sections</h3>
<div><input type="checkbox" value="personHeader"/>top header</div>
<div><input type="checkbox" value="objective"/>objective</div>
<div><input type="checkbox" value="skills"/>summary of skills</div>
<div><input type="checkbox" value="education"/>education</div>
<div><input type="checkbox" value="work"/>work experience</div>
<div><input type="checkbox" value="projects"/>projects</div>
<div><input type="checkbox" value="interests"/>interest</div>
<div><input type="checkbox" value="references"/>references</div>
</form>
</div>
<div id="objectiveForm" class="menuItem">
<form name="objectiveForm">
<h3>Select Objective</h3>
<xsl:call-template name="createObjectiveFormItems"/>
</form>
</div>
<div id="categoryForm" class="menuItem">
<form name="categoryForm">
<h3>Select Categories</h3>
<xsl:call-template name="createCategoryFormItems"/>
</form>
</div>
<div id="occupationForm" class="menuItem">
<form name="occupationForm">
<h3>Select Occupations</h3>
<xsl:call-template name="createOccupationFormItems"/>
</form>
</div>
<div id="printForm" class="menuItem">
<form name="printForm">
<input style="width: 100%" id="previewButton" type="button" name="preview" value="Preview"/>
<input style="width: 100%" id="printButton" type="button" name="print" value="Print"/>
</form>
</div>
<div id="fileOptions" class="menuItem">
<h3>File Options</h3>
<div><a id="openResume" href="/cgi-bin/rezquest/main.py?request=login" title="Get another resume">Open New</a></div>
<div><a id="exitresume" href="/rezquest/exit.html" title="Exit RezQuest">Exit</a></div>
</div>
<div id="copyRight">
<span><xsl:text disable-output-escaping="yes">©</xsl:text> 2002 by Refugee Media Networks.</span>
</div>
</div>
<div id="main">
<div id="personHeader" class="section">
<div id="personInfo">
<div id="residence" class="contactInfo">
<xsl:apply-templates select="resume/residenceList"/>
</div>
<div id="phone" class="contactInfo">
<xsl:apply-templates select="resume/phoneList"/>
</div>
<div id="email" class="contactInfo">
<xsl:apply-templates select="resume/emailList"/>
</div>
<div id="filler1"/>
</div>
<xsl:apply-templates select="resume/person"/>
</div>
<div id="objective" class="section">
<h2 class="title">Objective</h2>
<div class="content">
<xsl:apply-templates select="resume/objectiveList"/>
</div>
<div class="contentFiller"> </div>
</div>
<div id="skills" class="section">
<h2 class="title">Summary of Skills</h2>
<div class="content">
<xsl:apply-templates select="resume/skillList"/>
</div>
<div class="contentFiller"> </div>
</div>
<div id="education" class="section">
<h2 class="title">Education</h2>
<div class="content">
<xsl:apply-templates select="resume/educationList"/>
</div>
<div class="contentFiller"> </div>
</div>
<div id="work" class="section">
<h2 class="title">Work Experience</h2>
<div class="content">
<xsl:apply-templates select="resume/occupationList"/>
</div>
<div class="contentFiller"> </div>
</div>
<div id="projects" class="section">
<h2 class="title">Personal Projects</h2>
<div class="content">
<xsl:apply-templates select="resume/projectList"/>
<div class="contentFiller"> </div>
</div>
<div class="contentFiller"> </div>
</div>
<div id="interests" class="section">
<h2 class="title">Interests</h2>
<div class="content">
<xsl:apply-templates select="resume/interestList"/>
</div>
<div class="contentFiller"> </div>
</div>
<div id="references" class="section">
<h2 class="title">References</h2>
<div class="content">
<xsl:apply-templates select="resume/referenceList"/>
</div>
<div class="contentFiller"> </div>
</div>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="skillList">
<ul>
<xsl:for-each select="skill">
<li>
<xsl:attribute name="class">
<xsl:value-of select="@category"/>
</xsl:attribute>
<xsl:value-of select="description"/>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="objectiveList">
<ul>
<xsl:for-each select="objective">
<li>
<xsl:attribute name="id">objective<xsl:value-of select="@id"/></xsl:attribute>
<xsl:value-of select="description"/>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="residenceList">
<xsl:for-each select="residence">
<xsl:if test="@type='home'">
<div class="key">Residence</div>
<div class="value">
<div class="region">
<xsl:value-of select="address"/>
</div>
<div class="region">
<xsl:value-of select="city"/>
</div>
<div class="region">
<xsl:value-of select="state/@code"/>
</div>
<div class="region">
<xsl:value-of select="state/country/@code"/>
</div>
<div class="region">
<xsl:value-of select="zip"/>
</div>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="educationList">
<xsl:for-each select="education">
<xsl:if test="@degree='basc'">
<h2>
<xsl:value-of select="@major"/>
</h2>
<h3 class="subHead">
<xsl:value-of select="institution/name"/>
</h3>
<h3 class="subHead">
<span class="region">
<xsl:value-of select="institution/location/city"/>
</span>
<span class="region">
<xsl:value-of select="institution/location/state/@code"/>
</span>
</h3>
<h3 class="subHead"><xsl:value-of select="substring(startDate,1,7)"/> to <xsl:value-of select="substring(endDate,1,7)"/></h3>
<div class="contentFiller"/>
<div>
<ul>
<li>Bachelor of Applied Science</li>
</ul>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="occupationList">
<xsl:for-each select="occupation">
<!--xsl:if test="occupationType/@name='dsp software' or occupationType/@name='windows'"-->
<div class="subSection">
<xsl:attribute name="name"><xsl:value-of select="occupationType/@name"/></xsl:attribute>
<h2>
<xsl:value-of select="occupationType/title"/>
</h2>
<h3 class="subHead">
<xsl:value-of select="company/name"/>
</h3>
<h3 class="subHead">
<span class="region">
<xsl:value-of select="company/location/city"/>
</span>
<span class="region">
<xsl:value-of select="company/location/state/@code"/>
</span>
</h3>
<h3 class="subHead"><xsl:value-of select="substring(startDate,1,7)"/> to <xsl:value-of select="substring(endDate,1,7)"/></h3>
<div class="contentFiller"/>
<xsl:apply-templates select="summaryList"/>
</div>
<!--/xsl:if-->
</xsl:for-each>
</xsl:template>
<xsl:template match="referenceList">
<xsl:for-each select="reference">
<!--xsl:if test="@degree='basc'"-->
<div class="subSection">
<h2>
<xsl:value-of select="name"/>
</h2>
<h3 class="subHead">
<xsl:value-of select="@position"/>
</h3>
<h3 class="subHead">
<xsl:value-of select="company/name"/>
</h3>
<div class="contentFiller"/>
<div class="subHead"><xsl:value-of select="phone/@area"/>.<xsl:value-of select="phone/number"/><xsl:if test="phone/ext > 0"> ext.<xsl:value-of select="phone/ext"/></xsl:if></div>
<div class="subHead">
<xsl:value-of select="email"/>
</div>
<div id="filler2"/>
</div>
<!--/xsl:if-->
</xsl:for-each>
</xsl:template>
<xsl:template match="projectList">
<ul>
<xsl:for-each select="project">
<li>
<xsl:attribute name="class">
<xsl:value-of select="@category"/>
</xsl:attribute>
<xsl:value-of select="description"/>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="interestList">
<ul>
<xsl:for-each select="interest">
<xsl:choose>
<xsl:when test="position()!=last()">
<li>
<xsl:value-of select="@name"/>
</li>
</xsl:when>
<xsl:otherwise>
<li>
<xsl:attribute name="id">lastInterest</xsl:attribute>
<xsl:value-of select="@name"/>
</li>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="summaryList">
<ul>
<xsl:for-each select="summary">
<li>
<xsl:attribute name="class">
<xsl:value-of select="@category"/>
</xsl:attribute>
<xsl:value-of select="description"/>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="phoneList">
<xsl:for-each select="phone">
<div class="keyValue">
<div class="key">
<xsl:value-of select="@type"/>
</div>
<div class="value"><xsl:value-of select="@area"/>.<xsl:value-of select="number"/></div>
</div>
</xsl:for-each>
</xsl:template>
<xsl:template match="emailList">
<xsl:for-each select="email">
<xsl:if test="@type='school'">
<div class="keyValue">
<div class="key">email</div>
<div class="value">
<xsl:value-of select="address"/>
</div>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="person">
<div id="personName">
<div>
<span id="firstName">
<xsl:value-of select="firstName"/>
</span>
<span id="lastName">
<xsl:value-of select="lastName"/>
</span>
</div>
</div>
</xsl:template>
</xsl:stylesheet>
|