Hi,

This is not a question. Rather a tip for anyone struggling with xml in
Maven as I have recently.
Maven, ant, and the Sun jdk itself all handle the subject of different
xml parsers either poorly or not at all.
Here is a nice solution I have recently stumbled across.  I hope it is
proves of use to someone.

Download the mtxslt-1.5.jar jar file from here
http://mtxslt.sourceforge.net/  and place it in your maven repository.
I use a group called 'shared' for jar files not found in the standard
ibiblio maven repository but you can put it wherever you like if you set
the dependency correctly.

The file is an extension to the standard ant xslt (or style) task which
allows the xml parser to be selected on the fly.

Add the dependency to you root project.xml file including the root
classloader property as here:

<dependency>
     <groupId>shared</groupId>
     <artifactId>mtxslt</artifactId>
     <jar>mtxslt-1.5.jar</jar>
     <properties>
       <classloader>root</classloader>
     </properties>
   </dependency>

You will also need to do the same for any xml jar files you want to use:

   <dependency>
     <groupId>saxon</groupId>
     <artifactId>saxon</artifactId>
     <version>6.5.2</version>
     <properties>
       <classloader>root</classloader>
     </properties>
   </dependency>


Whilst it is possible to declare the classes in full each time, it is
easier to set these properties in the project.properties file thus:

#mtxslt helper properties
mtxslt.saxon6=org.xmLP.ant.taskdefs.optional.Saxon6Liaison
mtxslt.saxon7=org.xmLP.ant.taskdefs.optional.Saxon7Liaison
mtxslt.xalan2=org.xmLP.ant.taskdefs.optional.Xalan2Liaison
mtxslt.xdk9=org.xmLP.ant.taskdefs.optional.Oracle9Liaison


And finally declare the ant task in the root maven.xml file like this:

<taskdef name = "mtxslt" classname =
"org.xmLP.ant.taskdefs.xslt.XSLTProcess"/>


You should now be able to use saxon like this:
<mtxslt  processor="${mtxslt.saxon6}" in="infile.xml" out="outfile.xml"
style="stylesheet.xsl" />

If you want to use one of the other parsers you will also need to add
the relevant dependency as per the saxon example above.

This will then allow you to use a different parser only for this
specific task.  This means that Maven can continue to use its default
parser internally and you shouldn't have problems with plugins breaking
down.

There are links to some good ant based examples on the mtxslt web page.

Hope it helps someone, Allen.


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

Reply via email to