You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by va...@wanadoo.nl on 2004/04/03 10:28:43 UTC

Castor Transformer and Castor sample

Hi,

I'am allready using the castortransformer for a while. This is the version 
Michael Homeijer posted. This version worked with pre and post processing 
options for the marshalling of objects. Because of the need for a 
castorcommand, it was not posible to set sitemap parameters for the use of 
navigation like with Cocoon Actions.

To be brief I wanted to use castor in combination with actions.

So i did some debugging on the castortransformer shipped in the scratchpad.

I found the following issues.

The test.xml file is out dated:
- the latest version of the castor transformer uses marshal and unmarshal 
instead of InsertBean
-the castor namespace must be: http://apache.org/cocoon/castor/1.0

The test.xml should look like this:

<?xml version="1.0"?>
<zoo xmlns:castor="http://apache.org/cocoon/castor/1.0">
	<castor:marshal name="Mouse"/> 
	<castor:marshal name="Lion"/> 
	<castor:marshal name="Hamster" mapping="castor-mappings/test-
mapping_de.xml"/>
	<castor:marshal name="Wale"/>
	<castor:marshal name="Elefant" scope="session"/> 
	<castor:marshal name="Elefant" scope="request"/> 
</zoo>


The the Marshall class gives an exception that the system property for the sax 
parser is not set.


You can do this by setting the Systemproperty org.xml.sax.parser when you 
startup your web or app server.

Or you can use the static block together with the method xmlParserFoundAndSet 
in the castor transformer.
The code of the two is below.


I will post the complete java and xml files later this week, but it will work 
if you do as described above.

Regards Erwin.

	// Static initializer:
	static {
		// Try to find out which XML parser to use:
		// FIXME: This should be a Cocoon parser.
		if (xmlParserFoundAndSet
("org.apache.xerces.parsers.SAXParser")) {
			// Xerces / XML4J
		} else if (xmlParserFoundAndSet
("org.apache.crimson.jaxp.SAXParserImpl")) {
			// Crimson
		} else if (xmlParserFoundAndSet
("com.jclark.xml.sax.Driver")) {
			// James Clark XP
		} else if (xmlParserFoundAndSet
("com.microstar.xml.SAXDriver")) {
			// Aelfred
		} else {
			System.err.println("ERROR: No SAX XML parser 
found!");
		}
	}










	/**
	   * Code to specify the appropriate parser.
	   *
	   * @param qualifiedName DOCUMENT ME!
	   *
	   * @return DOCUMENT ME!
	   */
	  private static boolean xmlParserFoundAndSet(String qualifiedName) {
		  try {
			  Class.forName(qualifiedName, false, 
Thread.currentThread().getContextClassLoader());
		  } catch (ClassNotFoundException cnfe) {
			  return false;
		  }

		  System.setProperty("org.xml.sax.parser", qualifiedName);
		  System.out.println("Using SAX XML parser: " + 
qualifiedName);

		  return true;
	  }


Re: Castor Transformer and Castor sample

Posted by va...@wanadoo.nl.
Antonio,

It took a little while, but finaly found the time to create the castor patch.

The patch is created against the cocoon 2.1 cvs version from 10 April 2004 
about 19:30.


Here it is!


Kind regards,

Erwin van de Noort




Citeren Antonio Gallardo <ag...@agssa.net>:

> Thanks for the report.
> 
> Can you post a PATCH?
> 
> Best Regards,
> 
> Antonio Gallardo
> 
> 
> 




Re: Castor Transformer and Castor sample

Posted by Antonio Gallardo <ag...@agssa.net>.
Thanks for the report.

Can you post a PATCH?

Best Regards,

Antonio Gallardo