gpt4 book ai didi

xslt - Freemarker - XSLT 等价于 copy-of

转载 作者:行者123 更新时间:2023-12-04 17:06:46 25 4
gpt4 key购买 nike

我正在尝试在 XSLT 中模拟函数的副本,我希望在响应中输出节点中的所有内容。

使用这个模板

<#ftl ns_prefixes={"D": "http://milyn.codehaus.org/Smooks"} output_format="XML">
${Order.orderitem.@@markup}

在这里面临 2 个问题
  • 我得到的输出转换了 <、> 以及 XML 标签。我确实需要 XML 格式来转义 & 等无效字符。
  • 如何删除出现在每个节点中的名称景观

  • 我的回答是
    &lt;orderitem xmlns=&quot;http://milyn.codehaus.org/Smooks&quot;&gt;&lt;position&gt;1&lt;/position&gt;&lt;quantity&gt;1&lt;/quantity&gt;&lt;productid&gt;364&lt;/productid&gt;&lt;title&gt;The 40YearOld&lt;/title&gt;&lt;price&gt;29.98&lt;/price&gt;&lt;/orderitem&gt;&lt;orderitem xmlns=&quot;http://milyn.codehaus.org/Smooks&quot;&gt;&lt;position&gt;2&lt;/position&gt;&lt;quantity&gt;1&lt;/quantity&gt;&lt;productid&gt;299&lt;/productid&gt;&lt;title&gt;Pulp Fiction&lt;/title&gt;&lt;price&gt;29.99&lt;/price&gt;&lt;/orderitem&gt;

    输入是
    <Order xmlns="http://milyn.codehaus.org/Smooks" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance">
    <header>
    <orderid>1</orderid>
    <statuscode>0</statuscode>
    <netamount>59.97</netamount>
    <totalamount>64.92</totalamount>
    <tax>4.95</tax>
    <date>Wed Nov 15 13:45:28 EST 2006</date>
    </header>
    <customerdetails>
    <username>user1</username>
    <name>
    <firstname>Harry</firstname>
    <lastname>Fletcher</lastname>
    </name>
    <state>South Dakota</state>
    </customerdetails>
    <orderitem>
    <position>1</position>
    <quantity>1</quantity>
    <productid>364</productid>
    <title>The 40YearOld</title>
    <price>29.98</price>
    </orderitem>
    <orderitem>
    <position>2</position>
    <quantity>1</quantity>
    <productid>299</productid>
    <title>Pulp Fiction</title>
    <price>29.99</price>
    </orderitem>

    最佳答案

    防止自动转义:${Order.orderitem.@@markup?no_esc} . (不幸的是,XML 包装方式早于自动转义,所以它仍然如此......)

    防止重复xmlns -es...你不能。问题在于orderitem -s 至于 @@markup 没有共同的祖先可以知道,哪里有共同点xmlns可以解决这个问题,所以它做最安全的事情。

    关于xslt - Freemarker - XSLT 等价于 copy-of,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49518112/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com