Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 如何测量持续/持续的';粗体';要素_Xml_Xpath_Xquery_Xslt 2.0 - Fatal编程技术网

Xml 如何测量持续/持续的';粗体';要素

Xml 如何测量持续/持续的';粗体';要素,xml,xpath,xquery,xslt-2.0,Xml,Xpath,Xquery,Xslt 2.0,这里我们试着测量conscutive'bold'元素,即'or'。请参见以下示例: <?xml version="1.0" encoding="UTF-8"?> <root> <h1><bold>Abandonment of Trade Secret</bold></h1> <h2><bold>Abuse of Discretion.</bold>

这里我们试着测量conscutive'bold'元素,即'or'。请参见以下示例:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<h1><bold>Abandonment of Trade Secret</bold></h1>
<h2><bold>Abuse of Discretion.</bold> See <bold>Discretion of Court</bold></h2>
<h3>Licensing agreement, modifications to. See <bold>Licensing Agreements</bold></h3>
<h4><bold>Alternative Minimum Tax (AM</bold><bold>T)</bold></h4>
<h5><bold>Audits.</bold> See <bold>Trade Secre</bold><bold>t Audits</bold></h5>
<h6><bold>California Uniform Trade</bold><bold> Secrets Act (UTSA).</bold> See <bold>Uniform Trade Secrets Act, California (UTSA)</bold></h6>
<h7><bold>Charts, Checklists, Questionnaires, </bold><bold>and Tables</bold></h7>
<h8><bold>Competition.</bold> See <bold>Covenant Against Competition;</bold> <bold>Unfair Competition</bold></h8>
<h9>See also <bold>Internet;</bold> <bold>Websites</bold> <bold>URL</bold></h9>
<h10>See also <bold>Copyrights;</bold><bold> Intellectual Property; Patents; </bold><bold>Trademarks</bold></h10>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<h1><bold>Abandonment of Trade Secret</bold></h1>
<h2><bold>Abuse of Discretion.</bold> See <bold>Discretion of Court</bold></h2>
<h3>Licensing agreement, modifications to. See <bold>Licensing Agreements</bold></h3>
<h4><bold>Alternative Minimum Tax (AMT)</bold></h4>
<h5><bold>Audits.</bold> See <bold>Trade Secret Audits</bold></h5>
<h6><bold>California Uniform Trade Secrets Act (UTSA).</bold> See <bold>Uniform Trade Secrets Act, California (UTSA)</bold></h6>
<h7><bold>Charts, Checklists, Questionnaires, and Tables</bold></h7>
<h8><bold>Competition.</bold> See <bold>Covenant Against Competition; Unfair Competition</bold></h8>
<h9>See also <bold>Internet; Websites URL</bold></h9>
<h10>See also <bold>Copyrights; Intellectual Property; Patents; Trademarks</bold></h10>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">

<xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="*[bold]">
    <xsl:copy>
        <xsl:for-each-group select="*" group-adjacent=". instance of element(bold)">
            <xsl:choose>
                <xsl:when test="current-grouping-key()">
                    <xsl:copy>
                        <xsl:apply-templates select="current-group()/node()"/>
                    </xsl:copy>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="current-group()"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>
注意:如果其他节点正在“查看”,我们不会测量

输入XML:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<h1><bold>Abandonment of Trade Secret</bold></h1>
<h2><bold>Abuse of Discretion.</bold> See <bold>Discretion of Court</bold></h2>
<h3>Licensing agreement, modifications to. See <bold>Licensing Agreements</bold></h3>
<h4><bold>Alternative Minimum Tax (AM</bold><bold>T)</bold></h4>
<h5><bold>Audits.</bold> See <bold>Trade Secre</bold><bold>t Audits</bold></h5>
<h6><bold>California Uniform Trade</bold><bold> Secrets Act (UTSA).</bold> See <bold>Uniform Trade Secrets Act, California (UTSA)</bold></h6>
<h7><bold>Charts, Checklists, Questionnaires, </bold><bold>and Tables</bold></h7>
<h8><bold>Competition.</bold> See <bold>Covenant Against Competition;</bold> <bold>Unfair Competition</bold></h8>
<h9>See also <bold>Internet;</bold> <bold>Websites</bold> <bold>URL</bold></h9>
<h10>See also <bold>Copyrights;</bold><bold> Intellectual Property; Patents; </bold><bold>Trademarks</bold></h10>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<h1><bold>Abandonment of Trade Secret</bold></h1>
<h2><bold>Abuse of Discretion.</bold> See <bold>Discretion of Court</bold></h2>
<h3>Licensing agreement, modifications to. See <bold>Licensing Agreements</bold></h3>
<h4><bold>Alternative Minimum Tax (AMT)</bold></h4>
<h5><bold>Audits.</bold> See <bold>Trade Secret Audits</bold></h5>
<h6><bold>California Uniform Trade Secrets Act (UTSA).</bold> See <bold>Uniform Trade Secrets Act, California (UTSA)</bold></h6>
<h7><bold>Charts, Checklists, Questionnaires, and Tables</bold></h7>
<h8><bold>Competition.</bold> See <bold>Covenant Against Competition; Unfair Competition</bold></h8>
<h9>See also <bold>Internet; Websites URL</bold></h9>
<h10>See also <bold>Copyrights; Intellectual Property; Patents; Trademarks</bold></h10>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">

<xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="*[bold]">
    <xsl:copy>
        <xsl:for-each-group select="*" group-adjacent=". instance of element(bold)">
            <xsl:choose>
                <xsl:when test="current-grouping-key()">
                    <xsl:copy>
                        <xsl:apply-templates select="current-group()/node()"/>
                    </xsl:copy>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="current-group()"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>

商业秘密的放弃
滥用自由裁量权。见法院自由裁量权
许可协议,修改。见许可协议
替代最低税额(AMT)
审计。参见商业秘密审计
加州统一商业秘密法(UTSA)。参见《加利福尼亚州统一商业秘密法》(UTSA)
图表、检查表、问卷和表格
竞争。见《反竞争公约》;不正当竞争
另见互联网;网站网址
另见版权;知识产权;专利;商标
预期输出:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<h1><bold>Abandonment of Trade Secret</bold></h1>
<h2><bold>Abuse of Discretion.</bold> See <bold>Discretion of Court</bold></h2>
<h3>Licensing agreement, modifications to. See <bold>Licensing Agreements</bold></h3>
<h4><bold>Alternative Minimum Tax (AM</bold><bold>T)</bold></h4>
<h5><bold>Audits.</bold> See <bold>Trade Secre</bold><bold>t Audits</bold></h5>
<h6><bold>California Uniform Trade</bold><bold> Secrets Act (UTSA).</bold> See <bold>Uniform Trade Secrets Act, California (UTSA)</bold></h6>
<h7><bold>Charts, Checklists, Questionnaires, </bold><bold>and Tables</bold></h7>
<h8><bold>Competition.</bold> See <bold>Covenant Against Competition;</bold> <bold>Unfair Competition</bold></h8>
<h9>See also <bold>Internet;</bold> <bold>Websites</bold> <bold>URL</bold></h9>
<h10>See also <bold>Copyrights;</bold><bold> Intellectual Property; Patents; </bold><bold>Trademarks</bold></h10>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<h1><bold>Abandonment of Trade Secret</bold></h1>
<h2><bold>Abuse of Discretion.</bold> See <bold>Discretion of Court</bold></h2>
<h3>Licensing agreement, modifications to. See <bold>Licensing Agreements</bold></h3>
<h4><bold>Alternative Minimum Tax (AMT)</bold></h4>
<h5><bold>Audits.</bold> See <bold>Trade Secret Audits</bold></h5>
<h6><bold>California Uniform Trade Secrets Act (UTSA).</bold> See <bold>Uniform Trade Secrets Act, California (UTSA)</bold></h6>
<h7><bold>Charts, Checklists, Questionnaires, and Tables</bold></h7>
<h8><bold>Competition.</bold> See <bold>Covenant Against Competition; Unfair Competition</bold></h8>
<h9>See also <bold>Internet; Websites URL</bold></h9>
<h10>See also <bold>Copyrights; Intellectual Property; Patents; Trademarks</bold></h10>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">

<xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="*[bold]">
    <xsl:copy>
        <xsl:for-each-group select="*" group-adjacent=". instance of element(bold)">
            <xsl:choose>
                <xsl:when test="current-grouping-key()">
                    <xsl:copy>
                        <xsl:apply-templates select="current-group()/node()"/>
                    </xsl:copy>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="current-group()"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>

商业秘密的放弃
滥用自由裁量权。见法院自由裁量权
许可协议,修改。见许可协议
替代最低税额(AMT)
审计。参见商业秘密审计
加州统一商业秘密法(UTSA)。参见《加利福尼亚州统一商业秘密法》(UTSA)
图表、检查表、问卷和表格
竞争。见《反竞争公约》;不正当竞争
另见互联网;网站网址
另见版权;知识产权;专利;商标
XSLT代码:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<h1><bold>Abandonment of Trade Secret</bold></h1>
<h2><bold>Abuse of Discretion.</bold> See <bold>Discretion of Court</bold></h2>
<h3>Licensing agreement, modifications to. See <bold>Licensing Agreements</bold></h3>
<h4><bold>Alternative Minimum Tax (AM</bold><bold>T)</bold></h4>
<h5><bold>Audits.</bold> See <bold>Trade Secre</bold><bold>t Audits</bold></h5>
<h6><bold>California Uniform Trade</bold><bold> Secrets Act (UTSA).</bold> See <bold>Uniform Trade Secrets Act, California (UTSA)</bold></h6>
<h7><bold>Charts, Checklists, Questionnaires, </bold><bold>and Tables</bold></h7>
<h8><bold>Competition.</bold> See <bold>Covenant Against Competition;</bold> <bold>Unfair Competition</bold></h8>
<h9>See also <bold>Internet;</bold> <bold>Websites</bold> <bold>URL</bold></h9>
<h10>See also <bold>Copyrights;</bold><bold> Intellectual Property; Patents; </bold><bold>Trademarks</bold></h10>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<h1><bold>Abandonment of Trade Secret</bold></h1>
<h2><bold>Abuse of Discretion.</bold> See <bold>Discretion of Court</bold></h2>
<h3>Licensing agreement, modifications to. See <bold>Licensing Agreements</bold></h3>
<h4><bold>Alternative Minimum Tax (AMT)</bold></h4>
<h5><bold>Audits.</bold> See <bold>Trade Secret Audits</bold></h5>
<h6><bold>California Uniform Trade Secrets Act (UTSA).</bold> See <bold>Uniform Trade Secrets Act, California (UTSA)</bold></h6>
<h7><bold>Charts, Checklists, Questionnaires, and Tables</bold></h7>
<h8><bold>Competition.</bold> See <bold>Covenant Against Competition; Unfair Competition</bold></h8>
<h9>See also <bold>Internet; Websites URL</bold></h9>
<h10>See also <bold>Copyrights; Intellectual Property; Patents; Trademarks</bold></h10>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">

<xsl:template match="node()|@*">
    <xsl:copy>
        <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="*[bold]">
    <xsl:copy>
        <xsl:for-each-group select="*" group-adjacent=". instance of element(bold)">
            <xsl:choose>
                <xsl:when test="current-grouping-key()">
                    <xsl:copy>
                        <xsl:apply-templates select="current-group()/node()"/>
                    </xsl:copy>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="current-group()"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>


参考URL#

在本例中,文本和元素节点的内容混合在一起,因此需要

    <xsl:for-each-group select="node()" group-adjacent=". instance of element(bold)">

如果还有空白文本节点,则要使用

<xsl:template match="*[bold]">
    <xsl:copy>
        <xsl:for-each-group select="node()" group-adjacent=". instance of element(bold) or (. instance of text() and not(normalize-space()))">
            <xsl:choose>
                <xsl:when test="current-grouping-key()">
                    <xsl:copy>
                        <xsl:apply-templates select="current-group()"/>
                    </xsl:copy>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="current-group()"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

<xsl:template match="bold">
    <xsl:apply-templates/>
</xsl:template>


可能就足够了,但如果相邻组以空白文本节点开头,则有失败的风险。

在本例中,文本和元素节点的内容混合在一起,因此需要

    <xsl:for-each-group select="node()" group-adjacent=". instance of element(bold)">

如果还有空白文本节点,则要使用

<xsl:template match="*[bold]">
    <xsl:copy>
        <xsl:for-each-group select="node()" group-adjacent=". instance of element(bold) or (. instance of text() and not(normalize-space()))">
            <xsl:choose>
                <xsl:when test="current-grouping-key()">
                    <xsl:copy>
                        <xsl:apply-templates select="current-group()"/>
                    </xsl:copy>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="current-group()"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each-group>
    </xsl:copy>
</xsl:template>

<xsl:template match="bold">
    <xsl:apply-templates/>
</xsl:template>


可能就足够了,但如果相邻组以空白文本节点开头,则有失败的风险。

应用与@Martin Honnen中相同的技术-谢谢Martin,我尝试按照建议修改该条件,但它会合并所有“粗体”元素并删除“请参见”,这里我们只尝试合并“”或“”种情况。请编辑您的问题,并向我们展示您在问题中为每个相邻的组使用的XSLT。@Martin Honnen-谢谢,我们已经编辑了这个问题,您可以看到我们尝试过的XSLT代码。参考URL#应用与@Martin Honnen相同的技术-谢谢Martin,我尝试按照建议修改该条件,但它会合并所有“粗体”元素并删除“请参见”,这里我们只尝试合并“”或“”种情况。请编辑您的问题,并向我们展示您在问题中为每个相邻的组使用的XSLT。@Martin Honnen-谢谢,我们已经编辑了这个问题,您可以看到我们尝试过的XSLT代码。参考URL#感谢您的建议,它工作正常,但我们也希望案例中除了文本节点(如as)外,还有更大的空间,即参见互联网;网站网址。但这件事并不意味着什么。请建议@Umaima,请参阅编辑,如果这些问题得到解决,您可能还希望养成接受以前提出的问题的答案的习惯。感谢您的建议,它工作正常,但我们也希望案例中除了文本节点(如as)外,还有更多空间;网站网址。但这件事并不意味着什么。请建议@Umaima,请参见编辑,如果之前提出的问题得到解决,您可能还希望养成接受这些问题答案的习惯。