cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt P." <m...@area403.org>
Subject feeling deprecated and modifiable
Date Mon, 11 Jul 2005 06:59:03 GMT
Hello,

I've been looking at a way to modify a user's configuration file, stored
somewhere on the filesystem as an xml file. I apply the classic pattern
found in many cocoon sources, and transmogrify it with my sauce.

[...]
try
{
	parser =
	cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
	resolver =
	cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
	source
	= resolver.resolveURI("file:/tmp/" + username + "/configuration.xml");
	if ( source instanceof Packages.org.apache.excalibur.source.ModifiableSource)
	{
		java.lang.System.err.println("Modifiable source");
		var inputSource = new Packages.org.xml.sax.InputSource(source.getInputStream());
		var document = parser.parseDocument(inputSource);
		//var outputStream = source.getOutputStream();
		//var document = parser.parseDocument(outputStream);
		java.lang.System.err.println("configuration " + document.getElementsByTagName("cx:configuration").getLength());
		var configurationNode = document.getElementsByTagName("cx:configuration").item(0);
		var inputNode = document.createElement("cx:input");
		inputNode.setAttribute("id", inputId);
		var sqlNode = document.createElement("cx:sql-statement");
		sqlNode.appendChild(document.createTextNode(sqlStatement));
		inputNode.appendChild(sqlNode);
		configurationNode.appendChild(inputNode);
		source.refresh();
		//var outputStream = source.getOutputStream();
		//outputStream.flush();
		//outputStream.close();
	}
}

[...]

Now, the above works ok, except it doesn't save nothing (I thought the
refresh would...). I added the 3 lines at the end to get an output
stream from the source, but the effect is my configuration files
disappears mysteriously (at least to me).

I'd appreciate if someone could give me some insight into this.

Oh, and while at it, is there a preference between using the w3c dom
model, or the xerces one?

Cheers, 

Matt

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


Mime
View raw message