cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Søren Neigaard <neiga...@mobilethink.dk>
Subject SV: Newbie XSP question - why dosn't this work?
Date Fri, 12 Oct 2001 20:37:17 GMT
Maybe I should explain more :) Yes you are correct, getContacts() returns a
stream of XML
and it is the "<" and ">" in that stream that is getting encoded?

Here is all my files (the rest of the XSL is attached to the mail):

[XSP]

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="kontaktpersoner.xsl" type="text/xsl"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>

<xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
xmlns:pim="http://www.mobilethink.dk/pim">
<!-- xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core"
xmlns:pim="http://www.mobilethink.dk/pim" -->
<side>
	<pim:kontaktpersoner>
		<pim:nummer>12345678</pim:nummer>
	</pim:kontaktpersoner>

	<tipbox type="web">
		<b>Web:</b>
		Du kan oprette en gruppe og sende SMS til flere personer med ét klik.
	</tipbox>

	<tipbox type="sms">
		<b>SMS</b>
		Du kan også slå kontaktpersoner op fra mobilen. Send SMS-kommandoen FIND
navn til nr. 842. Læs mere her.
	</tipbox>


</side>
</xsp:page>


[Logicsheet]

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xsp="http://apache.org/xsp"
	xmlns:pim="http://www.mobilethink.dk/pim"
>  <!-- namespace for det taglib som filen en beregnet for skrives
ovenfor-->

<xsl:output encoding="ISO-8859-1" indent="yes" method="xml"/>

<xsl:template match="xsp:page">
	<xsp:page>
		<xsl:apply-templates select="@*"/>

<!-- Her kommer alle include'erne -->

		<xsp:structure>
			<xsp:include>java.util.*</xsp:include>
			<xsp:include>dk.mobilethink.test.businessobjects.*</xsp:include>
		</xsp:structure>

		<xsl:apply-templates/>
	</xsp:page>
</xsl:template>

<!-- Her kommer templates til de enkelte tags -->

<xsl:template match="pim:kontaktpersoner">
	<xsp:logic>
		String msg = ContactBO.getContacts(
			"<xsl:value-of select="pim:nummer"/>" <!-- osv, hvis der er andre
parametre -->
		);
		System.out.println("\n---> XML returned from BO:\n");
		System.out.println(msg);
		System.out.println("\n---\n");
	</xsp:logic>
	<xsp:expr>msg</xsp:expr>
</xsl:template>

<!-- Default match template, er altid den samme -->

<xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
    	<xsl:copy>
      		<xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
    	</xsl:copy>
</xsl:template>

</xsl:stylesheet>


[Transformsheet]

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:pim="http://www.mobilethink.dk/pim"
	xmlns:xsp="http://apache.org/xsp"
>

<xsl:output
	method="html"
	indent="yes"
	encoding="ISO-8859-1"
	doctype-system="http://www.w3.org/TR/REC-html40/loose.dtd"
	doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"
/>

<xsl:include href="statiskData.xsl"/>
<xsl:include href="kontaktpersonTabel.xsl"/>
<xsl:include href="tipbox.xsl"/>

<xsl:template match="*">
	<html>
		<head>
			<title>Kontakperson-test</title>
			<link rel="stylesheet" type="text/css" href="CSS/minTDKmobil_IE.css"/>
		</head>
		<body>
			<table width="592" class="indholds-felt" border="0" cellpadding="4"
cellspacing="0">
				<tr>
					<td colspan="2">
						<xsl:apply-templates select="pim:kontaktpersoner"/>
					</td>
				</tr>
				<tr>
					<xsl:apply-templates select="tipbox"/>
				</tr>
			</table>
		</body>
	</html>
</xsl:template>

<xsl:template match="text()"></xsl:template>

</xsl:stylesheet>


[ContactBO]

package dk.mobilethink.test.businessobjects;

import java.util.*;

public class ContactBO {

  public static String getContacts(String phonenumber) {
  	StringBuffer sb = new StringBuffer();
  	if (phonenumber != null && phonenumber.equalsIgnoreCase("12345678")) {
  		//sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
  		//sb.append("<!DOCTYPE data SYSTEM
\"http://localhost:8080/cocoon/hansi/dataformat.dtd\">\n");
  		sb.append("<data type=\"kontaktpersoner\">\n");
  		sb.append("<table><record type=\"contact\"><field
type=\"navn\">ALTS</field><field type=\"telefonNummer\"/><field
type=\"email\">alts@alts.dk</field></record><record type=\"contact\"><field
type=\"navn\">ALTS-Kantine (Carola)</field><field
type=\"telefonNummer\"/><field type=\"email\"/></record></table></data>");
  	} else {
  		//sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
  		//sb.append("<!DOCTYPE data SYSTEM \"dataformat.dtd\">\n");
  		sb.append("<error>Igen kontakter til dig min ven</error>");
  	}
	return sb.toString();
  }

}

-----Oprindelig meddelelse-----
Fra: Jeremy Aston [mailto:jeremyaston@yahoo.co.uk]
Sendt: 12. oktober 2001 02:06
Til: cocoon-users@xml.apache.org
Emne: RE: Newbie XSP question - why dosn't this work?


Hi Soren,

Am I correct in assuming that the getContacts() call returns a stream of XML
and it is the "<" and ">" in that stream that is getting encoded?

I have not tried exactly what you are doing so I do not have experience of
the problem however you may get some joy if you sound the returned XML
stream with a CDATA<[[ ]]> construct.  Really I need to try it to determine
if I am talking complete codswallop.  If you have no joy then send me all
the files, including your java, and I will see what I can do.

Regards

Jeremy

-----Original Message-----
From: Søren Neigaard [mailto:neigaard@mobilethink.dk]
Sent: 12 October 2001 17:28
To: cocoon-users@xml.apache.org
Subject: Newbie XSP question - why dosn't this work?


I have a XSP, a XSL and a logicsheet. Everything works fine, but one thing.
My logicsheet returns XML, but it encodes the "<" and the ">". Why and what
can I do to prevent this?

Here is my logicsheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xsp="http://apache.org/xsp"
	xmlns:pim="http://www.mobilethink.dk/pim"
>  <!-- namespace for det taglib som filen en beregnet for skrives
ovenfor-->

<xsl:output encoding="ISO-8859-1" indent="yes" method="xml"/>

<xsl:template match="xsp:page">
	<xsp:page>
		<xsl:apply-templates select="@*"/>

<!-- Her kommer alle include'erne -->

		<xsp:structure>
			<xsp:include>java.util.*</xsp:include>
			<xsp:include>dk.mobilethink.test.businessobjects.*</xsp:include>
		</xsp:structure>

		<xsl:apply-templates/>
	</xsp:page>
</xsl:template>

<!-- Her kommer templates til de enkelte tags -->

<xsl:template match="pim:kontaktpersoner">
	<xsp:logic>
		String msg = ContactBO.getContacts(
			"<xsl:value-of select="pim:nummer"/>" <!-- osv, hvis der er andre
parametre -->
		);
		System.out.println(msg);
	</xsp:logic>
	<xsp:expr>msg</xsp:expr>
</xsl:template>

<!-- Default match template, er altid den samme -->

<xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
    	<xsl:copy>
      		<xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
    	</xsl:copy>
</xsl:template>

</xsl:stylesheet>

Med venlig hilsen/Best regards
Søren Neigaard
-------------------------------
Mobilethink A/S
Arosgaarden
Åboulevarden 23, 5.sal
DK - 8000 Århus C
Telefon: +45 86207800
Direct: +45 86207810
Fax: +45 86207801


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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



_________________________________________________________

Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com




---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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