[Laszlo-dev] Anyone know how to set an ant property from an xpath expression? Or where to find javax.xml.xpath.XPath?
Henry Minsky
henry.minsky at gmail.com
Fri Jan 15 15:54:17 PST 2010
Maybe the javax.xml.xpath classes come in some other jar file that you need
to add
to your classpath? Some extra Java Enterprise Edition package or
something ?
On Fri, Jan 15, 2010 at 6:12 PM, P T Withington <ptw at pobox.com> wrote:
> I have a nifty table of OL versions:
>
> <?xml version="1.0" encoding="utf-8"?>
> <versions>
> <branch url="http://svn.openlaszlo.org/openlaszlo/trunk">
> <entry revision="15440" release="Latest" id="4.8.ptw" />
> </branch>
> <branch url="http://svn.openlaszlo.org/openlaszlo/branches/4.6">
> <entry revision="14738" release="Production" id="4.6.0" />
> <entry revision="14744" release="RC" id="4.6.1" />
> <entry revision="14781" release="Production" id="4.6.1" />
> <entry revision="14814" release="RC" id="4.6.2" />
> <entry revision="14827" release="Production" id="4.6.2" />
> <entry revision="14913" release="RC" id="4.6.3" />
> </branch>
> <branch url="http://svn.openlaszlo.org/openlaszlo/branches/4.7">
> <entry revision="15428" release="RC" id="4.7.0" />
> </branch>
> </versions>
>
> And I can get the url and revision from svn info. So I want to be able to
> look up the release and id with:
>
>
> /versions/branch[@url='${svninfo.entry(url)}']/entry[@revision<${svninfo.entry.commit(revision)}][last()][@release]
>
> /versions/branch[@url='${svninfo.entry(url)}']/entry[@revision<${svninfo.entry.commit(revision)}][last()][@id]
>
> I found a nifty script:
>
> <scriptdef name="xpath-query" language="javascript">
> <attribute name="query"/>
> <attribute name="xmlfile"/>
> <attribute name="addproperty"/>
>
> <![CDATA[
> importClass(java.io.FileInputStream);
> importClass(javax.xml.xpath.XPath);
> importClass(javax.xml.xpath.XPathConstants);
> importClass(javax.xml.xpath.XPathFactory);
> importClass(org.xml.sax.InputSource);
>
> var exp = attributes.get("query");
> var filename = attributes.get("xmlfile");
> var input = new InputSource(new FileInputStream(filename));
> var xpath = XPathFactory.newInstance().newXPath();
> var value = xpath.evaluate(exp, input, XPathConstants.STRING);
>
> self.project.setProperty( attributes.get("addproperty"), value
> );
>
> ]]>
>
> </scriptdef>
>
> But ant tells me it knows nothing about `javax`. Help?
>
>
>
--
Henry Minsky
Software Architect
hminsky at laszlosystems.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-dev/attachments/20100115/394351b1/attachment.html
More information about the Laszlo-dev
mailing list