0

我下载了适用于 java 的 Google Calendar API,并且对 xml 文件的内容感到非常困惑。我对java很陌生。我应该寻找哪些资源来了解如何操作这些 xml 文件的内容?以下是内容示例:

<!-- samples build Properties -->
  <property name="sample.calendar.basedir"
value="${build}/sample/calendar"/>
  <property name="sample.calendar.src.home"
value="${sample.calendar.basedir}"/>

具体来说,我试图弄清楚“$”的作用以及花括号之间的内容是什么。

4

2 回答 2

2

Edit: If you're really desperate, use grep.

$ cd /path/to/base/dir/
$ find . -type f | xargs grep "ant.file.calendar"

Then you can see all the places where it's used, and find where it's defined.


The ${} syntax refers to variables that are defined (a) in .properties files (b) between <properties> or <property> XML tags or (c) by other means, such as environment variables or runtime behavior.

To give you an example,

<?xml>
<project>
  <properties>
    <jetty.port>8080</jetty.port>
  </properties>
  <build>
    ... 
    <port>${jetty.port}</port>
  </build>
</project>

You might encounter the above in the pom.xml file for a Jetty webapp. You see how the ${jetty.port} property is defined between the <properties> tags. This is one way to define it.

In your case, the ${build} variable is defined somewhere, but it's impossible to say without looking at your directory. It may even be defined in the same XML file where you see it.

于 2013-03-10T22:59:29.483 回答
0

有问题的 XML 文件似乎是一个 Ant 构建文件。

如果您需要了解它,则需要阅读 Ant。它是一种构建软件的工具,您可以通过谷歌搜索“apache ant”来查找信息。

但也许你不需要了解它;也许你只需要运行它。也许你甚至不需要这样做。你没有说你想要达到的目标,所以很难说。

于 2013-03-11T08:36:01.353 回答