如果使用XSL样式表XML,则不同节点的值相同时,更改子节点的值

时间:2016-11-28 14:48:19

标签: xml xslt

我有几天新的XSL样式表,但我正在创建一个程序来操作XML,这些表格是一个惊人的帮助。我有两个需要检查的节点。

<Callout id="151" start="142" duration="20" scalar="1/1" mediaStart="25/1" mediaDuration="20/1">
    <Attributes>
        <Attribute id="190" name="vectorNode">
            <VectorNode id="191" kind="TypeWinSVG">
                <StringParameters>
                    <Parameter id="203" name="name">
                        <Keyframes>
                            <Keyframe id="204" time="0/1" value="Sketch Motion Perfect Rectangle" leadInLength="0/1"/>
                        </Keyframes>
                    </Parameter>
                </StringParameters>
            </VectorNode>
        </Attribute>
    </Attributes>

</Callout>

<Callout id="588" start="17" duration="20" scalar="1/1" mediaStart="0/1" mediaDuration="88/1" >
    <Attributes>
        <Attribute id="620"  name="vectorNode">
            <VectorNode id="621" kind="TypeWinText"  >
            </VectorNode>
        </Attribute>
    </Attributes>
</Callout>

如果第二个(不一定是索引(1)或第二个)的'kind'等于TypeWinText,请检查它们的起始值是否相等。如果他们什么都不做,但如果他们没有改变第一个<Callout>(并不总是第一个)value="Transparent Hotspot"

有多个Callout节点(全部在父媒体下)并且有多个这些检查。

一个现实的例子:

<Callout id="151" start="142" duration="20" scalar="1/1" mediaStart="25/1" mediaDuration="20/1">
    <Attributes>
        <Attribute id="190" name="vectorNode">
            <VectorNode id="191" kind="TypeWinSVG">
                <StringParameters>
                    <Parameter id="203" name="name">
                        <Keyframes>
                            <Keyframe id="204" time="0/1" value="Sketch Motion Perfect Rectangle" leadInLength="0/1"/>
                        </Keyframes>
                    </Parameter>
                </StringParameters>
            </VectorNode>
        </Attribute>
    </Attributes>

</Callout>

<Callout id="210" start="246" duration="20" scalar="1/1" mediaStart="25/1" mediaDuration="20/1">
    <Attributes>
        <Attribute id="190" name="vectorNode">
            <VectorNode id="191" kind="TypeWinSVG">
                <StringParameters>
                    <Parameter id="203" name="name">
                        <Keyframes>
                            <Keyframe id="204" time="0/1" value="Sketch Motion Perfect Rectangle" leadInLength="0/1"/>
                        </Keyframes>
                    </Parameter>
                </StringParameters>
            </VectorNode>
        </Attribute>
    </Attributes>        
</Callout>

<Callout id="151" start="294" duration="20" scalar="1/1" mediaStart="25/1" mediaDuration="20/1">
    <Attributes>
        <Attribute id="190" name="vectorNode">
            <VectorNode id="191" kind="TypeWinSVG">
                <StringParameters>
                    <Parameter id="203" name="name">
                        <Keyframes>
                            <Keyframe id="204" time="0/1" value="Sketch Motion Perfect Rectangle" leadInLength="0/1"/>
                        </Keyframes>
                    </Parameter>
                </StringParameters>
            </VectorNode>
        </Attribute>
    </Attributes>         
</Callout>



<Callout id="588" start="17" duration="20" scalar="1/1" mediaStart="0/1" mediaDuration="88/1" >
    <Attributes>
        <Attribute id="620"  name="vectorNode">
            <VectorNode id="621" kind="TypeWinText"  >
            </VectorNode>
        </Attribute>
    </Attributes>
</Callout>

<Callout id="588" start="246" duration="20" scalar="1/1" mediaStart="0/1" mediaDuration="88/1" >
    <Attributes>
        <Attribute id="620"  name="vectorNode">
            <VectorNode id="621" kind="TypeWinText"  >
            </VectorNode>
        </Attribute>
    </Attributes>
</Callout>

<Callout id="588" start="275" duration="20" scalar="1/1" mediaStart="0/1" mediaDuration="88/1" >
    <Attributes>
        <Attribute id="620"  name="vectorNode">
            <VectorNode id="621" kind="TypeWinText"  >
            </VectorNode>
        </Attribute>
    </Attributes>
</Callout>

<Callout id="588" start="294" duration="20" scalar="1/1" mediaStart="0/1" mediaDuration="88/1" >
    <Attributes>
        <Attribute id="620"  name="vectorNode">
            <VectorNode id="621" kind="TypeWinText"  >
            </VectorNode>
        </Attribute>
    </Attributes>
</Callout>

第一组中的第二和第三组将其“Sketch Motion Perfect Rectangle”的值更改为“Transparent Hotspot”,因为第一组的“start”值与第二组246和294的起始值匹配。将是文档中的其他起始值,但因为第二组只是kind = TypeWinText我们只关心这些节点。第一个不会改变,因为起始值不等于任何其他起始值。

0 个答案:

没有答案