首页 \ 问答 \ 在Freemarker模板中访问带有命名空间的DOM元素(Accessing DOM element with namespace in Freemarker template)

在Freemarker模板中访问带有命名空间的DOM元素(Accessing DOM element with namespace in Freemarker template)

我有以下XML

<wmi xmlns="http://www.exmple.com/XMLSchema/fulfillment/v1/order/orderShipment" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/XMLSchema/fulfillment/v1/order/orderShipment OrderShipmentNotification.xsd">
<wmiHeader>
    <fileID>693401.20160229.130342.3541254</fileID>
    <version>2.0.0</version>
    <messageType>FSN</messageType>
    <genDate>2016-02-29T13:03:42Z</genDate>
    <from>
    </from>
</wmiHeader>
<orderShipNotification>
    <shipmentHeader dateTimeCreated="2016-02-29T13:03:42Z" requestNumber="2574445351883" />
    <shipmentDetails actualShipmentDateTime="2016-02-29T12:18:54Z" carrierCode="XX" carrierMethodCode="XX-01">
        <shipmentPackDetails trackingNumber="9361289672090007124848" trackingURL="https://example.com/go/TrackConfirmAction_input?qtc_tLabels1=323434">
            <shipmentPackLineDetails requestLineNumber="1" partnerItemID="FXT-CC-LB" itemQtyShipped="1" />
        </shipmentPackDetails>
    </shipmentDetails>
</orderShipNotification>
</wmi>

当我尝试访问时,我在Freemarker模板中收到错误。

${orderShipNotification.shipmentDetails.@actualShipmentDateTime[0]!""}

如果我从文档中删除命名空间,它工作正常。 我从XML中删除了以下内容

xmlns="http://www.exmple.com/XMLSchema/fulfillment/v1/order/orderShipment" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/XMLSchema/fulfillment/v1/order/orderShipment OrderShipmentNotification.xsd"

我做了一些调查。 这是一个ftl指令。 但目前尚不清楚这将如何解决问题。 请让我知道如何访问属性。

 http://freemarker.incubator.apache.org/docs/ref_directive_ftl.html#ref.directive.ftl

I have the following XML

<wmi xmlns="http://www.exmple.com/XMLSchema/fulfillment/v1/order/orderShipment" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/XMLSchema/fulfillment/v1/order/orderShipment OrderShipmentNotification.xsd">
<wmiHeader>
    <fileID>693401.20160229.130342.3541254</fileID>
    <version>2.0.0</version>
    <messageType>FSN</messageType>
    <genDate>2016-02-29T13:03:42Z</genDate>
    <from>
    </from>
</wmiHeader>
<orderShipNotification>
    <shipmentHeader dateTimeCreated="2016-02-29T13:03:42Z" requestNumber="2574445351883" />
    <shipmentDetails actualShipmentDateTime="2016-02-29T12:18:54Z" carrierCode="XX" carrierMethodCode="XX-01">
        <shipmentPackDetails trackingNumber="9361289672090007124848" trackingURL="https://example.com/go/TrackConfirmAction_input?qtc_tLabels1=323434">
            <shipmentPackLineDetails requestLineNumber="1" partnerItemID="FXT-CC-LB" itemQtyShipped="1" />
        </shipmentPackDetails>
    </shipmentDetails>
</orderShipNotification>
</wmi>

I am getting error in Freemarker template when I am trying to access.

${orderShipNotification.shipmentDetails.@actualShipmentDateTime[0]!""}

If I delete the namespaces from the document it is working fine. I deleted the following content from the XML

xmlns="http://www.exmple.com/XMLSchema/fulfillment/v1/order/orderShipment" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/XMLSchema/fulfillment/v1/order/orderShipment OrderShipmentNotification.xsd"

I did some investigation. The is a ftl directive. But it is still not clear how this will solve the problem. Please let me know how I can access the attributes.

 http://freemarker.incubator.apache.org/docs/ref_directive_ftl.html#ref.directive.ftl

原文:https://stackoverflow.com/questions/35712198
更新时间:2024-04-11 22:04

最满意答案

数据库使用索引 。 这样,它可以快速找到与给定用户ID相关的数据。

取决于索引结构,占用空间等...有一个增益,即它不是搜索N列,而是搜索 - 例如 - log(N) 。 通过二十亿行的二分法搜索

N = 100,000,000,000

将会

Search(N) : search log2(N) = search (36 rows)

相反,搜索10 ^ 12行,只需要分析36行。

在你提到的情况下,朋友,每个用户可能有几个朋友,所以

user1 => (userX, userY, userZ, ...)
userX => (userU, userV, user1, ...)

意思是user1是userX,userY等的朋友...即你没有每个用户的唯一索引。 但是每个用户都有一个唯一的索引。

在Mysql上会是

UNIQUE(user1,user2)

意味着情侣(user1,user2)在表格中只有一次。 语法是

CREATE UNIQUE INDEX friendsindex ON friends(user1,user2)

friendsindex是索引名称, 朋友是表。 或者如您所说,将表主键声明为(user1,user2) (每个表的主键是唯一的)。

-

赢得游戏的策略基于相同的原则,该策略包括找到给定对象的确切价格。 假设价格在1到10000之间。你告诉价格,处理程序说+- 。 您必须尽可能少地尝试查找价格。 例如价格是6000。

您可以从1开始并将所有价格都提供到6000 (即6000次尝试),但您也可以继续进行二分法

  • 你:5000
  • 游戏玩家:+
  • 7500或(10000 - 5000)/ 2
  • -
  • 6250或(7500 - 5000)/ 2
  • -
  • 等等...

在每次迭代时将剩余范围除以2。 而不是6000次尝试,您可以在12次尝试中找到(log2(6000))。

-

关于对数

例如,如何在2^x = 1024找到x? 或者x = log2(1024)表示基数2中的对数为1024 (答案:10)。 在我们的故事中,具有基于二叉树的索引的1024行表需要10次尝试(最大)才能找到正确的元素(而不是1024最大值)。


The database makes use of indexes. This way it can find quickly data related to a given userID.

Depending on the index structure, space occupation etc... there is a gain, i.e. instead of searching N columns, it searches - for instance - log(N). A search by dichotomy of 100 billions rows

N = 100,000,000,000

would be

Search(N) : search log2(N) = search (36 rows)

Instead a searching 10^12 rows, only 36 rows have to be analyzed.

In the case you mention, friends, each user may have several friends, so

user1 => (userX, userY, userZ, ...)
userX => (userU, userV, user1, ...)

meaning user1 is friend with userX, userY etc... ie you don't have a unique index per user. But you have a unique index per couple of users.

on Mysql that would be

UNIQUE(user1,user2)

meaning the couple (user1,user2) is only once in the table. The syntax would be

CREATE UNIQUE INDEX friendsindex ON friends(user1,user2)

friendsindex being the index name, friends being the table. Or as you said, declaring the table primary key to be (user1,user2) (primary keys are unique per table).

--

The strategy to win a game that consists of finding the exact price of a given object is based on the same principle. Say the price is between 1 and 10000. You tell a price, and the handler says + or -. You have to find the price in as less tries as possible. E.g. the price is 6000.

You could start from 1 and give all prices until 6000 (ie 6000 tries), but you could also proceed by dichotomy

  • you: 5000
  • gamer: +
  • 7500 or (10000 - 5000)/2
  • -
  • 6250 or (7500 - 5000)/2
  • -
  • etc...

you divide the remaining range by 2 at each iteration. Instead of 6000 tries, you can find in 12 tries (log2(6000)).

--

About logarithms

For instance, how to find x in 2^x = 1024? Or x = log2(1024) meaning logarithm of 1024 in base 2 (answer: 10). In our story, a 1024 rows table having an index based on a binary tree would need 10 tries (max) to find the right element (instead of 1024 max).

相关问答

更多
  • dict对象的开销很大。 它取决于您的Python版本和您的系统架构,但取决于Python 3.5 64位 In [21]: sys.getsizeof({}) Out[21]: 288 所以猜测: 250*36e6*1e-9 == 9.0 因此,如果我创建了很多字典,那么这是我的内存使用量的下限(以千兆字节为单位) ,而不是list ! 不要将字典用作记录类型,而不是真正的用例,请使用namedtuple 。 为了得到这个比较的一个视图,让我们设置一个等效的元组列表: In [23]: Record ...
  • 您可以使用JDBC进行多次插入,如下所示使用批量插入。 import java.sql.Connection; import java.sql.Statement; //... Connection connection = new getConnection(); Statement statement = connection.createStatement(); for (Employee employee: employees) { String query = "insert int ...
  • 我想我现在要和Dapper一起去: http://code.google.com/p/dapper-dot-net/source/browse/Tests/Tests.cs Dapper绝对是数据库独立的,它处理继承 在上面的Tests.cs中搜索TestInheritance()以获取示例。 I think I'm going to go with Dapper for now: http://code.google.com/p/dapper-dot-net/source/browse/Tests/Tes ...
  • 这在很大程度上取决于您正在进行的搜索类型。 如果您的数据都是ID查找,那么将它放在RAM中可能会更快。 如果您的数据都是全扫描(没有索引),那么将它放在RAM中可能会更快。 如果您的数据使用索引,那么将其放入数据库可能会更快。 当然,数据库的大部分吸引力都是索引和通用查询接口,因此您必须权衡这些接口与原始速度的重要性。 如果不确切知道数据的性质和要对其进行的查询,就无法真正回答这个问题。 线上时间有其成本,BSON < - >本地编组也是如此,但索引搜索可以是O(log n),而不是通过简单的内存数据进行愚 ...
  • Tekpub MVC 3系列使用Massive进行数据访问,代码可以在这里找到 - https://github.com/tekpub/mvc3 The Tekpub MVC 3 series uses Massive for the data access, code can be found here - https://github.com/tekpub/mvc3
  • 代码更新后,更新到OP评论 杰德,把你的MoviesController改成这个 public class MoviesController : Controller { public ActionResult Index() { MovieTable dbMovies = new MovieTable(); dbMovies.All(); return View(dbMovies); } ... } 访问TekPub.com ...
  • Oracle已经在Java中提供了JavaDB。 它是Apache Derby的Oracle打包版本,Apache Derby是Apache的开源嵌入式数据库。 您无需添加外部库即可使用它。 请查看此处了解详细信息: http : //www.oracle.com/technetwork/java/javadb/overview/faqs-jsp-156714.html JavaDB is already provided by Oracle in Java. It is the Oracle packag ...
  • 您可以使用反向索引的概念。 它可能是这样的: 对文件进行排序。 对于字母表中的每个字符,请保留特定字符出现在特定位置的第一行和最后一行。 对于某个单词,获取所有范围并计算交集。 顺序很重要。 如果交叉点为空,请保留前一个。 如果最后交叉点为空,则该单词不存在。 例如:您计算了字符a出现在单词的第一个位置的范围(第一行和最后一行)。 对于第二个位置也是如此,依此类推。 您对字母表中的所有字符执行相同操作。 我们假设你想要“苹果”这个词。 您可以找到a出现在第一个位置的范围(设置A)。 p在第二个(设置B)和第 ...
  • 数据库使用索引 。 这样,它可以快速找到与给定用户ID相关的数据。 取决于索引结构,占用空间等...有一个增益,即它不是搜索N列,而是搜索 - 例如 - log(N) 。 通过二十亿行的二分法搜索 N = 100,000,000,000 将会 Search(N) : search log2(N) = search (36 rows) 相反,搜索10 ^ 12行,只需要分析36行。 在你提到的情况下,朋友,每个用户可能有几个朋友,所以 user1 => (userX, userY, userZ, ...) ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)