ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: xmlproperty-target reading properties
Date Wed, 19 Nov 2003 10:25:03 GMT
I used a XSL to transform your XML to a valid properties file. Then loading
and evaluating.
Because I need a newline after each property-line I used the $lineSep. That
was the quickest way, which
comes into my mind :-)


Jan


config.xml
----------
<configuration>
    <setup>
        <property name="a">1</property>
        <property name="b">2</property>
        <property name="c">3</property>
        <property name="d">4</property>
    </setup>
</configuration>



build.xml
---------
<project>
    <!-- Convert config to property file -->
    <xslt in="config.xml" style="config2property.xsl"
out="config.properties">
        <param name="lineSep" expression="${line.separator}"/>
    </xslt>

    <!-- load the file -->
    <property prefix="loaded" file="config.properties"/>

    <!-- access to properties -->
    <echo> </echo>
    <echoproperties prefix="loaded"/>
    <echo> </echo>
    <echo>loaded.a = &gt;&gt;&gt;${loaded.a}&lt;&lt;&lt; </echo>
</project>




config2property.xsl
-------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output indent="no" method="text" encoding="ISO-8859-1"/>

    <xsl:param name="lineSep"/>

<xsl:template match="property">
    <xsl:value-of select="@name"/>=<xsl:value-of select="."/><xsl:value-of
select="$lineSep"/>
</xsl:template>

</xsl:stylesheet>





> -----Original Message-----
> From: Sakke Wiik [mailto:sakke.wiik@netikos.fi]
> Sent: Wednesday, November 19, 2003 11:07 AM
> To: Ant Users List
> Subject: RE: xmlproperty-target reading properties
> 
> 
> Hi,
> The properties structure is not changeable due to a DTD.
> Are there plans to support this in the future, or are there
> any other way to solve this without using external ant tasks?
> 
> cheers,
> Sakke
> 
> > -----Original Message-----
> > From: Markku Saarela [mailto:markku.saarela@dnafinland.fi]
> > Sent: 19. marraskuuta 2003 11:46
> > To: Ant Users List
> > Subject: RE: xmlproperty-target reading properties
> > 
> > 
> > Hi,
> > 
> > No I see you point. You can specify config file like this
> > 
> > <configuration>
> >   <setup>
> >    <a>1</a>
> >    <b>2</b>
> >    <c>3</c>
> >    <d>4</d>
> >   </setup>
> > </configuration>
> > 
> > and use xmlproperty with\without semanticAttributes and
> > includeSemanticAttribute
> >   <target name="test-xmlproperty"
> >           description="test-xmlproperty">
> >     <xmlproperty file="config.xml"
> >                  semanticAttributes="true"
> >                  includeSemanticAttribute="true"/>
> >     <echo message="${configuration.setup.a}"/>
> >     <echo message="${configuration.setup.b}"/>
> >     <echo message="${configuration.setup.c}"/>
> >     <echo message="${configuration.setup.d}"/>
> >   </target>
> > 
> > and here is result:
> > 
> > test-xmlproperty:
> >      [echo] 1
> >      [echo] 2
> >      [echo] 3
> >      [echo] 4
> > 
> > rgds, Markku
> > 
> > -----Original Message-----
> > From: Sakke Wiik [mailto:sakke.wiik@netikos.fi]
> > Sent: 19. marraskuuta 2003 10:04
> > To: Ant Users List
> > Subject: RE: xmlproperty-target reading properties
> > 
> > 
> > Hi,
> > I can't get it to work with the semantic properties.
> > None of these works:
> > 
> > <echo message="${configuration.setup.name.a}"/>
> > <echo message="${configuration.setup.name(a)}"/>
> > <echo message="${configuration.setup.property.a}"/>
> > <echo message="${configuration.setup.property(a)}"/>
> > <echo message="${configuration.setup.property.name.a}"/>
> > <echo message="${configuration.setup.property.name(a)}"/>
> > <echo message="${configuration.setup.a}"/>,
> > <echo message="${configuration.setup(a)}"/>
> > cheers,
> > Sakke
> > 
> > > -----Original Message-----
> > > From: Markku Saarela [mailto:markku.saarela@dnafinland.fi]
> > > Sent: 19. marraskuuta 2003 8:38
> > > To: Ant Users List
> > > Subject: RE: xmlproperty-target reading properties
> > >
> > >
> > > Hi,
> > >
> > > Try this one with ant 1.6 beta2
> > >
> > > <xmlproperty file="somefile.xml"
> > >                 semanticAttributes="true"
> > >                 includeSemanticAttribute="true"/>
> > >
> > > rgds,
> > >
> > > Markku
> > >
> > > -----Original Message-----
> > > From: Sakke Wiik [mailto:sakke.wiik@netikos.fi]
> > > Sent: 18. marraskuuta 2003 15:04
> > > To: ant-user@jakarta.apache.org
> > > Subject: xmlproperty-target reading properties
> > >
> > >
> > > Hi,
> > > I'm using Ant 1.6beta2 and cannot figure out how to read the
> > > <property>-values one at a time from an xml-file with 
> this structure:
> > >
> > > <configuration>
> > >  <setup>
> > >   <property name="a">1</property>
> > >   <property name="b">2</property>
> > >   <property name="c">3</property>
> > >   <property name="d">4</property>
> > >  </setup>
> > > </configuration>
> > >
> > >
> > > I can get a list of all <property>-values as a 
> comma-separated list:
> > > <echo 
> message="${hibernate-configuration.session-factory.property}"/>,
> > > but how do I get each property by its name, for example "a"?
> > >
> > > cheers,
> > > Sakke
> > >
> > >
> > >
> > > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > >
> > >
> > >
> > > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > >
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message