Read key value pairings XML file via ant? -
i want read xml file below
<?xml version="1.0" encoding="utf-8"?> <classpath> <classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.ibm.ws.st.core.runtimeclasspathprovider/com.ibm.worklight"/> <classpathentry kind="con" path="com.worklight.studio.plugin.classpath.server_container"/> <classpathentry kind="src" path="server/java"/> <classpathentry kind="src" path="common"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.jre_container"/> <classpathentry kind="src" output="adapters/adp1/bin" path="adapters/agent/src"/> <classpathentry kind="src" output="adapters/adp2/bin" path="adapters/alerts/src"/> <classpathentry kind="src" output="adapters/adp3/bin" path="adapters/billing/src"/> <classpathentry kind="src" output="adapters/adp4/bin" path="adapters/client/src"/> <classpathentry kind="src" output="adapters/adp5/bin" path="adapters/category/src"/> </classpath>
i want read value of path
kind
"src"
. able path value not able imply condition on it. using following code.
<target name="xml"> <echo>test each</echo> <for list="${classpath.classpathentry.path}" param="letter" delimiter=","> <sequential> <echo message="path ::: @{letter}"/> </sequential> </for> </target>
it working fine path
values should value of path
kind
"src"
?
as stated in comment, following xslt parse classpath entries of kind=src , generate single line path statement.
getclasspath.xslt
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="text" version="1.0" encoding="utf-8" indent="yes"/> <xsl:template match="/classpath"> <xsl:text>path=</xsl:text> <xsl:for-each select="classpathentry[@kind='src']"> <xsl:value-of select="@path"/> <xsl:text>;</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>
then following ant task:
<xslt style='getclasspath.xslt' in='classpath.xml' out='classpath.properties' />
Comments
Post a Comment