Igor
Igor

Reputation: 1464

How to read a parameter passed by maven on my stylesheet XSL?

I'm running this command:

mvn org.codehaus.mojo:xml-maven-plugin:transform "-DAPP=testingapp"

And inside my XSL I'm transforming a graphml to a HTML and I want to display this app name on the top of my HTML. How do I read this attribute that I'm passing on the command line on my xsl?

Thank you!

Upvotes: 1

Views: 294

Answers (1)

Diego
Diego

Reputation: 444

Yes. It is possible.

In your pom.xml

<configuration>
   <transformationSets>
      <transformationSet>
         <parameters>
            <parameter>
               <name>APP</name>
               <value>${APP}</value>
            </parameter>
         </parameters>
      </transformationSet>
   </transformationSets>
</configuration>

In your xsl file

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
   <xsl:output method="xml" indent="yes" />
   <xsl:param name="APP" />

   <xsl:value-of select="$APP"/>
</xsl:stylesheet>

You will need to declare in pom.xml and repeat in your xsl file. This is the trick.

Note: This also work for xslt-2.0

Upvotes: 1

Related Questions