0

我有一个具有以下结构的 xml:

<metadata style="basic">
    <zonelist>
        <zone name="z0" type="poster" id="null" x="558" y="1550" w="180" h="260"/>
        <zone name="z1" type="poster" id="null" x="738" y="1550" w="180" h="260"/>
        <zone name="z2" type="poster" id="null" x="918" y="1550" w="180" h="260"/>
        <zone name="z3" type="poster" id="null" x="1098" y="1550" w="180" h="260"/>
        <zone name="z4" type="poster" id="null" x="1278" y="1550" w="180" h="260"/>
        <zone name="z5" type="poster" id="null" x="1458" y="1550" w="180" h="260"/>
        <zone name="z6" type="poster" id="null" x="1638" y="1550" w="180" h="260"/>
    </zonelist>
    <library_animation_clips>
        <animation_clip id="intro" start="0.25" end="1.25" start_pos="0.25" speed="1" loop="false" reverse="false"/>
        <animation_clip id="outro" start="1.26" end="2.26" start_pos="1.26" speed="1" loop="false" reverse="false"/>
        <animation_clip id="disabled" start="2.27" end="2.27" start_pos="2.27" speed="1" loop="false" reverse="false"/>
        <animation_clip id="active" start="2.28" end="2.28" start_pos="2.28" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i0_p" start="2.29" end="3.10" start_pos="2.29" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i0_i2_n" start="3.11" end="3.12" start_pos="3.11" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i1_i0_p" start="3.13" end="3.14" start_pos="3.16" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i1_i2_n" start="3.15" end="3.16" start_pos="3.17" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i2_i1_p" start="3.17" end="3.18" start_pos="3.18" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i2_i3_n" start="3.19" end="3.20" start_pos="0.25" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i3_i2_p" start="3.21" end="3.22" start_pos="0.25" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i3_i4_n" start="3.23" end="3.24" start_pos="0.25" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i4_i3_p" start="3.25" end="3.26" start_pos="0.25" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i4_i5_n" start="3.27" end="3.28" start_pos="0.25" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i5_i4_p" start="3.29" end="3.30" start_pos="0.25" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i5_i6_n" start="3.31" end="3.32" start_pos="0.25" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i6_i5_p" start="3.33" end="3.34" start_pos="0.25" speed="1" loop="false" reverse="false"/>
        <animation_clip id="i6_n" start="3.35" end="3.36" start_pos="0.25" speed="1" loop="false" reverse="false"/>
    </library_animation_clips>
</metadata>

我需要一个 xslt 来仅从“library_animation_clips”节点复制内部文本,以便输出 xml 看起来像:

<Renderer Type="ThreeD">
        <ThreeDRenderer>
            <animation_clip id="intro" start="0.25" end="1.25" start_pos="0.25" speed="1" loop="false" reverse="false"/>
            <animation_clip id="outro" start="1.26" end="2.26" start_pos="1.26" speed="1" loop="false" reverse="false"/>
            <animation_clip id="disabled" start="2.27" end="2.27" start_pos="2.27" speed="1" loop="false" reverse="false"/>
            <animation_clip id="active" start="2.28" end="2.28" start_pos="2.28" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i0_p" start="2.29" end="3.10" start_pos="2.29" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i0_i2_n" start="3.11" end="3.12" start_pos="3.11" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i1_i0_p" start="3.13" end="3.14" start_pos="3.16" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i1_i2_n" start="3.15" end="3.16" start_pos="3.17" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i2_i1_p" start="3.17" end="3.18" start_pos="3.18" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i2_i3_n" start="3.19" end="3.20" start_pos="0.25" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i3_i2_p" start="3.21" end="3.22" start_pos="0.25" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i3_i4_n" start="3.23" end="3.24" start_pos="0.25" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i4_i3_p" start="3.25" end="3.26" start_pos="0.25" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i4_i5_n" start="3.27" end="3.28" start_pos="0.25" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i5_i4_p" start="3.29" end="3.30" start_pos="0.25" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i5_i6_n" start="3.31" end="3.32" start_pos="0.25" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i6_i5_p" start="3.33" end="3.34" start_pos="0.25" speed="1" loop="false" reverse="false"/>
            <animation_clip id="i6_n" start="3.35" end="3.36" start_pos="0.25" speed="1" loop="false" reverse="false"/>
        </ThreeDRenderer>
    </Renderer>

请让我知道如何实现这一目标?

4

1 回答 1

1

下面的小样式表应该可以完成这项工作:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="metadata">
    <Renderer Type="ThreeD">
      <ThreeDRenderer>
        <xsl:apply-templates select="library_animation_clips/*"/>
      </ThreeDRenderer>
    </Renderer>
  </xsl:template>

  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
于 2012-05-07T07:25:34.843 回答