xslt-2.0 相关问题

将此标记用于特定于XSL Transformations版本2.0的问题,而不是其他版本。

添加分号符号“;”到元素的值

我有变量“cond_in”作为“文档节点”类型。例如, 价值1 ...

回答 1 投票 0

XSLT 中的 for 循环缺少什么?

我尝试从下面给定的 XML 编写 XSLT,但没有得到正确的输出。 我尝试从下面给定的 XML 编写 XSLT,但没有得到正确的输出。 <?xml version="1.0" encoding="UTF-8"?> <n0:EPCISDocument xmlns:n0="urn:epcglobal:epcis:xsd:1" schemaVersion="1.2" creationDate="2024-03-12T14:28:47.272374Z"> <EPCISBody> <EventList> <AggregationEvent> <parentID>urn:epc:id:sscc:0361958.1000010007</parentID> <childEPCs> <epc>urn:epc:id:sgtin:539150714.0666.354159881283</epc> <epc>urn:epc:id:sgtin:539150714.0666.438941790942</epc> </childEPCs> </AggregationEvent> <AggregationEvent> <parentID>urn:epc:id:sscc:0361958.1000010008</parentID> <childEPCs> <epc>urn:epc:id:sgtin:539150714.0666.497811017409</epc> <epc>urn:epc:id:sgtin:539150714.0666.600301574096</epc> </childEPCs> </AggregationEvent> <AggregationEvent> <parentID>urn:epc:id:sscc:0361958.0001052872</parentID> <childEPCs> <epc>urn:epc:id:sscc:0361958.1000010007</epc> <epc>urn:epc:id:sscc:0361958.1000010008</epc> </childEPCs> </AggregationEvent> </EventList> </EPCISBody> </n0:EPCISDocument> ................................................ ...................................................... ...................... ------------------------------------------------- ---------------------------- 实际产量- <?xml version="1.0" encoding="UTF-8"?> <tns:despatchAdvice xmlns:tns="urn:ean.ucc:deliver:2"> <despatchAdviceLogisticUnitLineItem> <logisticUnitIdentification> <serialShipmentContainerCode> <serialShippingContainerCode>urn:epc:id:sscc:0361958.1000010007</serialShippingContainerCode> </serialShipmentContainerCode> </logisticUnitIdentification> <levelId> <levelIdentification>urn:epc:id:sscc:0361958.1000010007</levelIdentification> </levelId> <despatchAdviceItemContainmentLineItem> <listForEachItem> <serialNumber>urn:epc:id:sscc:0361958.1000010007</serialNumber> </listForEachItem> </despatchAdviceItemContainmentLineItem> </despatchAdviceLogisticUnitLineItem> <despatchAdviceLogisticUnitLineItem> <logisticUnitIdentification> <serialShipmentContainerCode> <serialShippingContainerCode>urn:epc:id:sscc:0361958.1000010007</serialShippingContainerCode> </serialShipmentContainerCode> </logisticUnitIdentification> <levelId> <levelIdentification>urn:epc:id:sscc:0361958.1000010007</levelIdentification> </levelId> <despatchAdviceItemContainmentLineItem> <listForEachItem> <serialNumber>urn:epc:id:sscc:0361958.1000010008</serialNumber> </listForEachItem> </despatchAdviceItemContainmentLineItem> </despatchAdviceLogisticUnitLineItem> <despatchAdviceLogisticUnitLineItem> <logisticUnitIdentification> <serialShipmentContainerCode> <serialShippingContainerCode>urn:epc:id:sscc:0361958.1000010007</serialShippingContainerCode> </serialShipmentContainerCode> </logisticUnitIdentification> <levelId> <levelIdentification>urn:epc:id:sscc:0361958.1000010007</levelIdentification> </levelId> <despatchAdviceItemContainmentLineItem> <listForEachItem> <serialNumber>urn:epc:id:sscc:0361958.1000010007</serialNumber> </listForEachItem> </despatchAdviceItemContainmentLineItem> </despatchAdviceLogisticUnitLineItem> <despatchAdviceLogisticUnitLineItem> <logisticUnitIdentification> <serialShipmentContainerCode> <serialShippingContainerCode>urn:epc:id:sscc:0361958.1000010007</serialShippingContainerCode> </serialShipmentContainerCode> </logisticUnitIdentification> <levelId> <levelIdentification>urn:epc:id:sscc:0361958.1000010007</levelIdentification> </levelId> <despatchAdviceItemContainmentLineItem> <listForEachItem> <serialNumber>urn:epc:id:sscc:0361958.1000010008</serialNumber> </listForEachItem> </despatchAdviceItemContainmentLineItem> </despatchAdviceLogisticUnitLineItem> <despatchAdviceLogisticUnitLineItem> <logisticUnitIdentification> <serialShipmentContainerCode> <serialShippingContainerCode>urn:epc:id:sscc:0361958.1000010007</serialShippingContainerCode> </serialShipmentContainerCode> </logisticUnitIdentification> <levelId> <levelIdentification>urn:epc:id:sscc:0361958.1000010007</levelIdentification> </levelId> <despatchAdviceItemContainmentLineItem> <listForEachItem> <serialNumber>urn:epc:id:sscc:0361958.1000010007</serialNumber> </listForEachItem> </despatchAdviceItemContainmentLineItem> </despatchAdviceLogisticUnitLineItem> <despatchAdviceLogisticUnitLineItem> <logisticUnitIdentification> <serialShipmentContainerCode> <serialShippingContainerCode>urn:epc:id:sscc:0361958.1000010007</serialShippingContainerCode> </serialShipmentContainerCode> </logisticUnitIdentification> <levelId> <levelIdentification>urn:epc:id:sscc:0361958.1000010007</levelIdentification> </levelId> <despatchAdviceItemContainmentLineItem> <listForEachItem> <serialNumber>urn:epc:id:sscc:0361958.1000010008</serialNumber> </listForEachItem> </despatchAdviceItemContainmentLineItem> </despatchAdviceLogisticUnitLineItem> </tns:despatchAdvice> 预期产出- <?xml version="1.0" encoding="UTF-8"?> <ns3:despatchAdvice xmlns:ns3="urn:ean.ucc:deliver:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <despatchAdviceLogisticUnitLineItem> <logisticUnitIdentification> <serialShipmentContainerCode> <serialShippingContainerCode>urn:epc:id:sscc:0361958.0001052872</serialShippingContainerCode> </serialShipmentContainerCode> </logisticUnitIdentification> <levelId> <levelIdentification>urn:epc:id:sscc:0361958.0001052872</levelIdentification> </levelId> </despatchAdviceLogisticUnitLineItem> <despatchAdviceLogisticUnitLineItem> <logisticUnitIdentification> <serialShipmentContainerCode> <serialShippingContainerCode>urn:epc:id:sscc:0361958.1000010007</serialShippingContainerCode> </serialShipmentContainerCode> </logisticUnitIdentification> <parentLevelId> <levelIdentification>urn:epc:id:sscc:0361958.0001052872</levelIdentification> </parentLevelId> <despatchAdviceItemContainmentLineItem> <listForEachItem> <serialNumber>urn:epc:id:sgtin:539150714.0666.354159881283</serialNumber> </listForEachItem> <listForEachItem> <serialNumber>urn:epc:id:sgtin:539150714.0666.438941790942</serialNumber> </listForEachItem> </despatchAdviceItemContainmentLineItem> </despatchAdviceLogisticUnitLineItem> <despatchAdviceLogisticUnitLineItem> <logisticUnitIdentification> <serialShipmentContainerCode> <serialShippingContainerCode>urn:epc:id:sscc:0361958.1000010008</serialShippingContainerCode> </serialShipmentContainerCode> </logisticUnitIdentification> <parentLevelId> <levelIdentification>urn:epc:id:sscc:0361958.0001052872</levelIdentification> </parentLevelId> <despatchAdviceItemContainmentLineItem> <listForEachItem> <serialNumber>urn:epc:id:sgtin:539150714.0666.497811017409</serialNumber> </listForEachItem> <listForEachItem> <serialNumber>urn:epc:id:sgtin:539150714.0666.600301574096</serialNumber> </listForEachItem> </despatchAdviceItemContainmentLineItem> </despatchAdviceLogisticUnitLineItem> </ns3:despatchAdvice> 下面是我尝试过的 XSLT 代码,但没有给出预期的输出。 <xsl:template match="/"> <tns:despatchAdvice> <xsl:for-each select="/ns0:EPCISDocument/EPCISBody/EventList/AggregationEvent"> <xsl:for-each select="/ns0:EPCISDocument/EPCISBody/EventList/AggregationEvent[contains(childEPCs/epc, 'sscc')]/childEPCs/epc"> <despatchAdviceLogisticUnitLineItem> <logisticUnitIdentification> <serialShipmentContainerCode> <serialShippingContainerCode> <xsl:value-of select="/ns0:EPCISDocument/EPCISBody/EventList/AggregationEvent/parentID"/> </serialShippingContainerCode> </serialShipmentContainerCode> </logisticUnitIdentification> <levelId> <levelIdentification> <xsl:value-of select="/ns0:EPCISDocument/EPCISBody/EventList/AggregationEvent/parentID"/> </levelIdentification> </levelId> <despatchAdviceItemContainmentLineItem> <listForEachItem> <serialNumber> <xsl:value-of select="."/> </serialNumber> </listForEachItem> </despatchAdviceItemContainmentLineItem> </despatchAdviceLogisticUnitLineItem> </xsl:for-each> </xsl:for-each> </tns:despatchAdvice> </xsl:template> 有人可以建议我编写的 XSLT 代码中缺少什么吗?请建议如何从 XSLT 获得正确的输出。这是场景- 在输入文件中我们有三个AggregationEvent,循环应该跟随三次。 在输入文件的最后一个 AggregationEvent 中,我们有两个子 epc。在第一个循环中,应为serialShippingContainerCode 和levelIdentification 显示parentID 的值。在第二个循环中,parentID 的值应出现在parentLevelId 下的levelIdentification 中,并且第一个AggregationEvent 的parentID 应出现在serialShipmentContainerCode 下的serialShippingContainerCode 中。在第二个循环中,只有第一个 AggregationEvent 的 childEPCs/epc 应填充其序列号值。在第三个循环中,parentID 的值应出现在parentLevelId 下的levelIdentification 中,并且第一个AggregationEvent 的parentID 应出现在serialShipmentContainerCode 下的serialShippingContainerCode 中。在第三个循环中,只有第二个 AggregationEvent 的 childEPC/epc 才应填充其序列号值。 xsl:for-each 指令会更改上下文。在 for-each 中,您应该使用相对路径,而不是绝对路径。 你写 for each /a/b for each /a/b/c value of /a/b/c/d 应该是 for each /a/b for each c value of d

回答 1 投票 0

遇到XML中的空标签时添加空格

我使用 Apache FOP 创建 PDF。 我的 XML 的一部分如下所示。基本上,我试图将标签的全部内容按原样放入 PDF 中,但我在这里遇到了一些挑战。 我想要...

回答 1 投票 0

当我想创建具有不同标准的两个组时,使用组相邻的 XSLT

我有一个 HTML 文件,我想将其转换为表单。 文本字段 复选框字段 我有一个 HTML 文件,我想将其转换为表单。 <p class="textfield">Text field</p> <p class="checkboxfield">Check Box field</p> <p class="drop_downlistfield">Drop-down list field 1</p> <p class="drop_downlistfield">Drop-down list field 2</p> <p class="drop_downlistfield">Drop-down list field 3</p> <p class="radiobuttonfield">Radio Button field 1</p> <p class="radiobuttonfield">Radio Button field 2</p> <p class="radiobuttonfield">Radio Button field 3</p> <p class="submitbuttonfield">Submit button</p> 为此,我必须创建组:带有 class="drop_downlistfield" 的段落必须成为一组: <select> <option value="Drop-down list field 1">Drop-down list field 1</option> <option value="Drop-down list field 2">Drop-down list field 2</option> <option value="Drop-down list field 3">Drop-down list field 3</option> </select> 并且 class="radiobuttonfield" 的段落必须成为另一个组,按其 @name 属性分组。 <input type="radio" id="ID_1929_6" name="radiogroup"></input> <label for="ID_1929_6">Radio Button field 1</label> <input type="radio" id="ID_1929_7" name="radiogroup"></input> <label for="ID_1929_7">Radio Button field 2</label> <input type="radio" id="ID_1929_8" name="radiogroup"></input> <label for="ID_1929_8">Radio Button field 3</label> 我可以创建一个群组: <xsl:for-each-group select="table|p|ul|ol" group-adjacent="(@class='radiobuttonfield')"> 但我很难创建两个。这将创建一个包含两者的组: <xsl:for-each-group select="table|p|ul|ol" group-adjacent="(@class='radiobuttonfield') or (@class='drop_downlistfield')"> 如何将此输入片段分成两个单独的组? 只需按值@class 的值对它们进行分组即可。像这样的东西: <xsl:template match="/*"> <div> <xsl:for-each-group select="table|p|ul|ol" group-adjacent="@class"> <xsl:choose> <xsl:when test="@class='drop_downlistfield'"> <select> <xsl:apply-templates select="current-group()"/> </select> </xsl:when> <xsl:when test="@class='radiobuttonfield'"> <xsl:apply-templates select="current-group()"> <!-- some business logic is needed for naming the radiogroup --> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="current-group()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </div> </xsl:template>

回答 1 投票 0

如何为 Apache FOP 目录中的每个图像创建页面序列

假设我有一个包含 n 张图像的目录。我想每页添加一张图像。 例如 : 在名为“Images”的目录中,我有以下两张图像: newpage0.jpg 和 newpage1.jpg 我...

回答 1 投票 0

在 Mapforce 中添加迄今为止的天数

我有一个日期格式为 20230101 的 XML,在映射它时需要为此日期添加 60 天。这是一个随机日期,因此它总是会变化,并且我们正在使用 XSLT2。我想不通...

回答 1 投票 0

XSLT 删除重复的子节点

我有一个源输入 XML,我需要根据两个子节点删除重复记录。我是 XSLT 的新手,一直在 XSLT 1.0 和 2.0 中尝试各种方法来完成此任务,但没有...

回答 1 投票 0

尝试拉回两个条件之间的期望值

XML: 下面是尝试以下两种方法但不返回任何值的示例 XML。我在模板匹配或条件上做错了什么吗 ...

回答 1 投票 0

如何检测丢失的文件而不抛出错误

我提到了xsl中的xml文件路径,但我想暂时删除文件夹中的那个xml文件,并且我总是想保留在xsl中。但是当我删除它时显示警告。 我提到了xsl中的xml文件路径,但我想暂时删除文件夹中的那个xml文件,并且我总是想保留在xsl中。但是当我删除它时显示警告。 <xsl:apply-templates mode="replaceVariables" select="document('../Folder_1/Test.xml')"> </xsl:apply-templates> 我从Test.xml中删除了Folder_1。当我运行时,出现以下错误 Engine name: Saxon-PE 9.9.1.7 Severity: warning Description: I/O error reported by XML parser processing file:/C:/Work/Folder_1/Test.xml: C:/Work/Folder_1/Test.xml (The system cannot find the file specified) Start location: 674:48 Length: 1 即使 xml 文件在相应的提到的文件夹中删除,它在转换时也不应该显示错误。 在 XSLT 2.0 及更高版本中,有 XPath 2.0 及更高版本的函数 doc-available 例如doc-available('../Folder_1/Test.xml'),因此您可以在 xsl:if 周围使用 xsl:apply-templates 检查,或者您甚至可以在 select 表达式的谓词中使用该检查。

回答 1 投票 0

文件夹文件不可用,正在经历错误

我提到了xsl中的xml文件路径,但我想暂时删除文件夹中的那个xml文件,并且我总是想保留在xsl中。但是当我删除它时显示警告。 我提到了xsl中的xml文件路径,但我想暂时删除文件夹中的那个xml文件,并且我总是想保留在xsl中。但是当我删除它时显示警告。 <xsl:apply-templates mode="replaceVariables" select="document('../Folder_1/Test.xml')"> </xsl:apply-templates> 我从Test.xml中删除了Folder_1。当我运行时,出现以下错误 Engine name: Saxon-PE 9.9.1.7 Severity: warning Description: I/O error reported by XML parser processing file:/C:/Work/Folder_1/Test.xml: C:/Work/Folder_1/Test.xml (The system cannot find the file specified) Start location: 674:48 Length: 1 即使 xml 文件在相应的提到的文件夹中删除,它在转换时也不应该显示错误。 在 XSLT 2.0 及更高版本中,有 XPath 2.0 及更高版本的函数 doc-available 例如doc-available('../Folder_1/Test.xml'),因此您可以在 xsl:if 周围使用 xsl:apply-templates 检查,或者您甚至可以在 select 表达式的谓词中使用该检查。

回答 1 投票 0

XSLT 为输入 XML 中的每个分隔符位置分配变量

在我的 XSLT 中,我需要将值分配给名为 FODepartment_LX 的变量,其中 X 表示从最左侧分隔符开始的分隔符 (+) 的位置,最大位置为 10。如果...

回答 1 投票 0

XSLT - 将单个属性分离为具有属性的多个元素

我有一些源 XML,其中包含对一个属性内多个值的交叉引用。我需要将它们分成具有属性值的自己不同的元素。 输入 XML: B... 我有一些源 XML,其中包含对一个属性内多个值的交叉引用。我需要将它们分成具有属性值的自己不同的元素。 输入XML: <p>Blah blah blah <xref ref-type="bibr" rid="ref004 ref005 ref006 ref007">4&#x2013;7</xref>.</p> 所需的输出 XML: <p>Blah blah blah <xref ref-type="bibr" rid="ref004">4</xref><xref ref-type="bibr" rid="ref005"/><xref ref-type="bibr" rid="ref006"/>&#x2013;<xref ref-type="bibr" rid="ref007">7</xref>.</p> 注意中间的 2 个交叉引用变成了空元素。 我有以下 XSLT,但它没有给我正确的输出 - 它将属性值作为元素内容插入。 <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="xref"> <xsl:variable name="rid" select="@rid"/> <xsl:choose> <xsl:when test="contains($rid, ' ')"> <!-- Multiple references --> <xsl:variable name="refs" select="tokenize($rid, ' ')"/> <xsl:for-each select="$refs"> <xsl:if test="position() > 1"> <xsl:text> </xsl:text> </xsl:if> <xsl:variable name="refNum" select="substring-after(., 'ref')"/> <xsl:element name="xref"> <xsl:attribute name="ref-type">bibr</xsl:attribute> <xsl:attribute name="rid"> <xsl:value-of select="concat('ref', $refNum)"/> </xsl:attribute> <xsl:value-of select="."/> </xsl:element> </xsl:for-each> </xsl:when> <xsl:otherwise> <!-- Single reference --> <xsl:element name="xref"> <xsl:attribute name="ref-type">bibr</xsl:attribute> <xsl:attribute name="rid"> <xsl:value-of select="$rid"/> </xsl:attribute> <xsl:value-of select="."/> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:template> 我想我通过使用得到了预期的结果: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="xref[contains(@rid, ' ')]"> <xsl:variable name="ref" select="text()"/> <xsl:for-each select="tokenize(@rid, ' ')"> <xsl:choose> <xsl:when test="position()=1"> <xref ref-type="bibr" rid="{.}"> <xsl:value-of select="substring-before($ref, '&#x2013;')"/> </xref> </xsl:when> <xsl:when test="position()=last()"> <xsl:text>&#x2013;</xsl:text> <xref ref-type="bibr" rid="{.}"> <xsl:value-of select="substring-after($ref, '&#x2013;')"/> </xref> </xsl:when> <xsl:otherwise> <xsl:text> </xsl:text> <xref ref-type="bibr" rid="{.}"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> </xsl:stylesheet> 但这主要是基于根据您的单个示例猜测规则是什么......

回答 1 投票 0

如何根据子节点的条件获取父节点?

我有以下xml: 数字 ...

回答 1 投票 0

将 xml 转换保存在新的 xml 文件中

嘿嘿! 我有一个 xslt 文件来转换我的 xml,它运行得很好:) 但我只在氧气终端中得到结果,而不是在单独的文件中。 我试过: 嘿! 我有一个 xslt 文件来转换我的 xml,它运行得很好:) 但我只能在氧气终端中获得结果,而不是在单独的文件中。 我尝试过: <xsl:stylesheet xmlns="http://www.tei-c.org/ns/1.0" xmlns:telota="http://www.telota.de" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xpath-default-namespace="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="xs" version="2.0"> <xsl:result-document href="new_badius.xml"/> 这给了我错误:“元素 xsl:result-document 不得直接出现在 xsl:stylesheet 中” 尝试了一些层次结构的变化: <xsl:template match="node()|@*"> <xsl:copy> <xsl:result-document href="new_file.xml"/> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> 或 <xsl:template match="node()|@*"> <xsl:result-document href="new_file.xml"/> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> 这给了我错误只能创建一个 new_file.xml (它是空的) 我应该把<xsl:result-document href="new_file.xml"/>放在哪里,或者有更好的方法将我的结果保存为.xml吗? xsl:result-document属于模板,哪个模板显然取决于您的XML输入结构、样式表结构以及结果文档的数量和想要的内容。 另请注意,oXygen 允许您配置一个转换场景,您可以在其中定义将主要结果写入到您可以定义名称的文件中,请参阅 https://www.oxygenxml.com/doc/versions/26.1/ ug-editor/topics/the-output-tab.html.

回答 1 投票 0

如何按照计划代码的顺序获取每个元素值

我需要表行应按照代码值的顺序获取 输入 xml 我有: 20000 我需要表行应按照代码值的顺序获取 输入我有的xml: <Group> <Maps> <Map> <Code>20000</Code> </Map> <Map> <Code>30000</Code> </Map> </Maps> <Details> <Detail> <Code>30000</Code> <Description>Benefit</Description> </Detail> <Detail> <Code>20000</Code> <Description>Non-Benefit</Description> </Detail> </Details> </Group> XSL 我已经使用变量尝试了以下操作: <xsl:template match="Group"> <xsl:variable name="MapCode" select="Maps/Map/Code"/> <row> <entry>Code</entry> <xsl:for-each select="Maps/Map"> <entry> <p> <xsl:value-of select="Code"/> </p> </entry> </xsl:for-each> </row> <row> <entry>Level</entry> <xsl:for-each select="Details/Detail[Code=$MapCode]"> <entry> <p> <xsl:value-of select="Description"/> </p> </entry> </xsl:for-each> </row> </xsl:template> 我得到的实际输出: <row> <entry>Code</entry> <entry> <p>20000</p> </entry> <entry> <p>30000</p> </entry> </row> <row> <entry>Level</entry> <entry> <p>Benefit</p> </entry> <entry> <p>Non-Benefit</p> </entry> </row> 预期输出应该是: <row> <entry>Code</entry> <entry> <p>20000</p> </entry> <entry> <p>30000</p> </entry> </row> <row> <entry>Level</entry> <entry> <p>Non-Benefit</p> </entry> <entry> <p>Benefit</p> </entry> </row> 根据 Code 订单匹配,应选择 Description 值。我将变量用于 Code 匹配。但它仍然错误地选择了 Description 值。所以描述应该按照代码顺序选择。 我猜你想做类似的事情: XSLT 2.0 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:key name="detail-by-code" match="Detail" use="Code" /> <xsl:template match="/Group"> <xsl:variable name="headings" select="Maps/Map" /> <table> <!-- header --> <row> <xsl:for-each select="$headings"> <entry> <p> <xsl:value-of select="Code"/> </p> </entry> </xsl:for-each> </row> <!-- data --> <xsl:for-each select="Details"> <xsl:variable name="current-row" select="." /> <row> <xsl:for-each select="$headings"> <entry> <p> <xsl:value-of select="key('detail-by-code', Code, $current-row)"/> </p> </entry> </xsl:for-each> </row> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet>

回答 1 投票 0

XML 节点值的 OR 条件

我需要检查XML节点的值。 但为什么这不起作用呢? 我需要检查XML节点的值。 但为什么这不起作用? <xsl:if test="(applicationData/remittingAccount/paymentMethodCode != 'ABC' or applicationData/remittingAccount/paymentMethodCode != 'XYZ')"> 我也尝试过这个 <xsl:if test="(applicationData/remittingAccount/paymentMethodCode != 'ABC') or (applicationData/remittingAccount/paymentMethodCode != 'XYZ')"> 还有这个 <xsl:if test="applicationData/remittingAccount/paymentMethodCode != 'ABC' or applicationData/remittingAccount/paymentMethodCode != 'XYZ'"> 请帮忙! 您还没有解释您想要检查的内容,但是那些在 XPath 通用比较运算符的语义上苦苦挣扎的人可能想要检查,例如not(applicationData/remittingAccount/paymentMethodCode = ('ABC', 'XYZ')) 而不是你的尝试。仅当 applicationData/remittingAccount/paymentMethodCode 都不等于 ABC 或 XYZ 时,该检查才为真。 测试: test="node != 'ABC' or node != 'XYZ'" 当节点不存在时,将返回 false only。 在所有其他情况下,即使只有一个节点,测试也始终为 true - 因为节点的字符串值不能同时为“ABC”和“XYZ”,因此至少其中一个语句将说实话。 您可能正在寻找 test="not(node = 'ABC' or node = 'XYZ')" 如果没有节点具有这些字符串值,则为真。

回答 2 投票 0

具有多个 LineItems 的 Xml 到 Json

我正在尝试将 xml 转换为 json,但在 xml 到 json 转换期间未形成多个行项目。我们总是在 xml 消息中包含单个或多个 Lineitem,其名称与“vpoItemLi...

回答 1 投票 0

为什么这个属性选择没有返回值?

我需要在 XSLT 中使用某种字典,以便在给定一个键时我可以取回一个值。我知道有更正式的方法可以做到这一点,但它们与我的问题无关。 当给定

回答 1 投票 0

从不同的子节点 XSLT 填充递归元素

我正在尝试向下查看 XML 文档中的某个级别,选择不同的值并为每个不同的值填充新元素。例如。获取输入 xml <

回答 1 投票 0

XML/XSLT:以不同的方式设计类似的标记场景

我有两种情况,在 XML 中的 标签内使用 标签: 标签包含纯文本和偶尔的 标签(典型用途): 这是一句话... 我有两种情况,在 XML 中的 <b> 标签内使用 <p> 标签: <p>标签包含纯文本和偶尔的<b>标签(典型用途): <p>This is a sentence with a <b>bold</b> word.</p> <p>标签仅包含<b>标签: <p><b>This is a subsection title</b></p> 我可以仅在场景 2 中使用 XSLT 2.0 更改 <b> 标签的字体大小吗? 我知道我可以轻松地使用 CSS 的 outputclass 属性和样式,但长话短说,这不足以满足我的需求。 匹配 p[not(text())]/b 的模板将仅处理那些没有任何同级文本节点的 b 元素。 如果没有您尝试的更多内容,最简洁的挑战可能就是添加样式属性。因此,在这里我只会为您提供可能用于样式属性的片段以及不选择具有非空白同级节点的方法。 <xsl:attribute name="style"> <xsl:value-of select="'font-size:3em;'"/> </xsl:attribute> 至于如何选择,如果没有更多的 XML (HTML),您正尝试更新或修复未在 XSLT 中发布的内容,则不容易识别。 <xsl:template match="p/b"> <xsl:attribute name="style" select="concat('font-size: ', '3em', 'em;')"/> </xsl:template> preceding-sibling::node()[not(self::text()[normalize-space()='')][1][self::text()] 应该足以检查第一个不是空白文本节点的前同级节点是文本节点 诸如新行和缩进之类的空白是它们自己的文本节点,因此您可能需要将类似的内容添加到样式表中。 <xsl:strip-space elements="*"/>

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.