Thanks for all the suggestions. I discovered something. In the Test java class I wrote I was creating and using a DOMParser directly. In my custom task I was doing the following:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse();

When I placed this code in my test application the XInclude did not work.

Could someone please shed some light as to what is happening? How is the above approach different than creating a DOMParser directly. I read that the DocumentBuilder way was preferred but I did not understand the difference. Any and all information will help.

Doesn't the DocumentBuilder approach still use a DOMParser under the hood?

Thanks again!

Doug


Brian Agnew wrote:

xmltask will perform an inclusion (not using xinclude semantics, mind).

Brian

http://www.oopsconsultancy.com/software/xmltask

Emmanouil Batsis wrote:

Hi Douglas,

You might be interested in xcluder [1], my xinclude task, or the configuration code of the xerces based helper [2] in it.

[1] http://sourceforge.net/projects/xcluder
[2] com.geekologue.tasks.xcluder.XIncludeProcXerces

hth,

Manos



Douglas Lochart wrote:

All,

I have written a custom Task that loads an xml document, runs it through a jaxb like system to load java objects and then pass the root object on to Velocity for template transformations. The xml documents are describing web pages and I wanted the ability for the xml docs to include common xml sections (like navigation sections) using XInclude. I have a standalone java app that will load the xml doc and dumps the result out and you can see that the XInclude worked. I have placed the proper xercesImpl and xml-apis in $ANT_HOME/lib and when I try to run my task the xml parsing portion fails to execute the XInclude semantics. I strongly believe that its the configuration that is causing the problem. In order to get XInclude to work you have to change the parser configuration and the recomended way to do that is to set a system property like such:

-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=xerces.parsers.XIncludeParserConfiguration


In my custom task I did a System.getProperty() on "org.apache.xerces.xni.parser.XMLParserConfiguration" and discovered that it was not there. It appears as though when ant sets up the project it makes the system properties available to the project but seems to remove them from the environment. Are my assumptions correct?


The only other way to change the configuration is JRE wide by creating a xerces.properties file in the JRE/lib directory. I don't want a system wide change and should not have to do that. I feel the answer to my dilemna is an easy one but one that escapes me.

Thanks in advance!

Doug Lochart
Ace Technologies Inc.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to