Flex 4 E4X 按属性过滤具有未定义的变量

发布于 2024-09-16 06:28:31 字数 553 浏览 5 评论 0 原文

我有一些 xml,我正在尝试使用 e4x 过滤它。我的 e4x 语句如下所示:

model.config.source.fees..fee.(@min<amount).@amount

我的 xml 如下所示:

<flex>
  <fees>
    <fee type="credit" min="0.00" max="200.00" amount="6.00"/>
    <fee type="credit" min="200.01" max="370.00" amount="10.00"/>
  </fees>
</flex>

运行 e4x 语句时,我收到一条错误消息: 错误#1065:未定义变量@min。

但是,如果我将语句更改为 model.config.source.fees..fee.@min ,它将返回所有 min 属性值的 xmllist,所以至少在该声明中定义了 min 。为什么原来的声明不起作用?

I have some xml and I am trying to filter it using e4x. My e4x statement looks like this:

model.config.source.fees..fee.(@min<amount).@amount

My xml looks liks this:

<flex>
  <fees>
    <fee type="credit" min="0.00" max="200.00" amount="6.00"/>
    <fee type="credit" min="200.01" max="370.00" amount="10.00"/>
  </fees>
</flex>

When the e4x statement is run, I get an error message:
Error #1065: Variable @min is not defined.

But if I change my statement to model.config.source.fees..fee.@min it will return an xmllist of all the min attribute values, so min is defined, at least in that statement. Why doesnt the original statement work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小苏打饼 2024-09-23 06:28:31

当您使用 @min 时,它要求所有费用节点都定义了 min 属性。它适用于您的示例 xml,但也许您在其他测试数据中缺少 @min

但是,如果使用这种格式:

model.config.source.fees..fee.(parseFloat(attribute('min')) < amount).@amount

它将处理所有节点,无论该属性是否存在。

When you use @min<amount it requires that all fee nodes have the min attribute defined. It works for your example xml but maybe you were missing @min in your other test data.

However, if you use this format:

model.config.source.fees..fee.(parseFloat(attribute('min')) < amount).@amount

It will handle all nodes whether the attribute is there or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文