cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven Larsen" ...@homecentricity.com>
Subject RE: XSP tag library problem C1.8
Date Tue, 16 Jan 2001 04:37:05 GMT
If I put my logic in the xml file (business_default.xml), it works perfect
(always has) so I know logic and code is alright. If I put it in the xsl
file (transformtoHTML.xsl below), it doesn't give me any errors, but it also
doesn't see my code in the compiled java file and doesn't produce the
desired date string in the resulting HTML. I know it's probably me doing
something stupid, but I can't catch it... Sorry about the namespace typo (to
much cut and paste during debug is starting to take its toll)
-steve

/************ business_default.xml with logic ************/
<?xml version="1.0" encoding="UTF-8"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="transformtoHTML.xsl" type="text/xsl"?>
<xsp:page language="java"
		xmlns:xsp="http://www.apache.org/1999/XSP/Core"
		xmlns:hc="http://www.homecentricity.com/2001/XSP/Core"
>
		<xsp:structure>
			<xsp:include>java.text.SimpleDateFormat</xsp:include>
		</xsp:structure>
		<xsp:logic>
			/* returns today's date with a specific format */
			private static String todaysDate(Date date, String pattern) {
				if (pattern == null || pattern.length() == 0) {
					pattern = "yyyy-MMM-dd";
				}
				return (new SimpleDateFormat(pattern)).format(date);
			}
		</xsp:logic>
<Page>

	<PageTitle>My Business</PageTitle>
	<PageType>Index4</PageType>
	<Date><xsp:expr>todaysDate(new Date(), "EEEE MMMM dd,
yyyy")</xsp:expr></Date>
</Page>
</xsp:page>
/******************* end business_default.xml ****************/

/***************** transformtoHTML ********************/
<?xml version="1.0" encoding="UTF-8"?>
<?cocoon-process type="xsp"?>
<xsl:stylesheet version="1.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:xsp="http://www.apache.org/1999/XSP/Core"
		xmlns:hc="http://www.homecentricity.com/2001/XSP/Core"
>
<xsl:output media-type="text/html" method="html"/>

<xsl:template match="xsp:page">
<xsp:page>
		<xsp:structure>
			<xsp:include>java.text.SimpleDateFormat</xsp:include>
		</xsp:structure>
		<xsp:logic>
			/* returns today's date with a specific format */
			private static String todaysDate(Date date, String pattern) {
				if (pattern == null || pattern.length() == 0) {
					pattern = "yyyy-MMM-dd";
				}
				return (new SimpleDateFormat(pattern)).format(date);
			}
		</xsp:logic>
</xsp:page>
	<xsl:apply-templates/>
</xsl:template>

<xsl:template match="Page">
<html>
	<head>
		<title><xsl:value-of select="PageTitle"/></title>
	</head>
	<body>
		<xsl:apply-templates select="Date"/><br/>
	</body>
</html>

</xsl:template>

<xsl:template match="Date">
Date is	<xsl:apply-templates select="hc:todaysDate"/>
</xsl:template>

<xsl:template match="hc:todaysDate">
	<xsp:expr>
		todaysDate(new Date(), "<xsl:value-of select="@format"/>")
	</xsp:expr>
</xsl:template>
</xsl:stylesheet>
/*****************end transformtoHTML **************/

_____________________________________________

Steven J. Larsen
email: sl@homecentricity.com
web: www.homecentricity.com
_____________________________________________


-----Original Message-----
From: Donald Ball [mailto:balld@webslingerZ.com]
Sent: Monday, January 15, 2001 10:44 PM
To: Steven Larsen
Cc: cocoon-users@xml.apache.org
Subject: RE: XSP tag library problem C1.8


On Mon, 15 Jan 2001, Steven Larsen wrote:

> Thanks for the suggestion. My test example doesn't do justice to why my
> usage is this way, but suffice it to say architecturally (sp?), it seems
to
> have some merit to me at this point given the scale I have in mind.
Anyhow,
> I tried what you said and created an xsp page from the get-go (see below).
> It still gave me the exact same errors as before. Why is the java
> compilation working except for my logicsheet includes and functions not
> being added in? This seems to be the crux of the problem. Any other
thoughts
> or suggestions would be greatly welcomed as I'm at wits end.

the namespace uri you attach to the xsp namespace prefix in your
logicsheet is incorrect:

<?xml version="1.0" encoding="UTF-8"?>
<?cocoon-process type="xsp"?>
<xsl:stylesheet version="1.0"
                xmlns:xsp="http://www.w3.org/1999/XSP/Core"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:hc="http://www.homecentricity.com/2001/XSP/Core"
>
<xsl:template match="xsp:page">

furthermore, the cocoon-process PI is extraneous here.

in general, when trying to debug logicsheet problems, try applying the
logicsheet to your xsp page by hand and see what you get. you will get
good clues that way.

- donald


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org



Mime
View raw message