使用XSLT将Panasonic P2 XML转换为Telestream Vantage XML

时间:2017-05-21 21:53:04

标签: xml xslt

我在从一个XML中提取信息并将其嵌入到另一个XML中时遇到问题。源XML来自Panasonic P2摄像机。在相机上拍摄的每个剪辑都会产生一个XML边车。我想从P2 XML中提取一些变量并将它们嵌入到目标XML中 - 格式化以便与Telestream Vantage一起使用。

我使用目标(Vantage)XML作为模板构建了一个XSLT,并使用<xsl:value-of...语句嵌入了我的源变量。这在需要构建类似XSLT的其他实例中工作正常,但是使用来自Panasonic P2相机的这种特定源XML失败。

这是源“Panasonic P2”XML:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<P2Main xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:schemas-Professional-Plug-in:P2:ClipMetadata:v3.0">
  <ClipContent>
    <ClipName>0001Y1</ClipName>
    <GlobalClipID>060A2B340101010501010D431300000021E314B9117805CB0080458250D62215</GlobalClipID>
    <Duration>2148</Duration>
    <EditUnit>1001/30000</EditUnit>
    <Relation>
      <OffsetInShot>93840</OffsetInShot>
      <GlobalShotID>060A2B340101010501010D4313000000C1731FB0117805EC0080458250D62215</GlobalShotID>
      <Connection>
        <Top>
          <ClipName>0005CE</ClipName>
          <GlobalClipID>060A2B340101010501010D431300000069721FB0117805C70080458250D62215</GlobalClipID>
          <P2SerialNo.>ACZ15I0318</P2SerialNo.>
        </Top>
        <Previous>
          <ClipName>001555</ClipName>
          <GlobalClipID>060A2B340101010501010D4313000000665D92B8117805DF0080458250D62215</GlobalClipID>
          <P2SerialNo.>ACZ15I0318</P2SerialNo.>
        </Previous>
      </Connection>
    </Relation>
    <EssenceList>
      <Video ValidAudioFlag="false">
        <VideoFormat>MXF</VideoFormat>
        <Codec>DV100_1080/59.94i</Codec>
        <FrameRate DropFrameFlag="true">59.94i</FrameRate>
        <StartTimecode>12:10:53:29</StartTimecode>
        <StartBinaryGroup>230F6007</StartBinaryGroup>
        <AspectRatio>16:9</AspectRatio>
        <VideoIndex>
          <StartByteOffset>32768</StartByteOffset>
          <DataSize>1031040000</DataSize>
        </VideoIndex>
      </Video>
      <Audio>
        <AudioFormat>MXF</AudioFormat>
        <SamplingRate>48000</SamplingRate>
        <BitsPerSample>16</BitsPerSample>
        <AudioIndex>
          <StartByteOffset>32768</StartByteOffset>
          <DataSize>6880472</DataSize>
        </AudioIndex>
      </Audio>
      <Audio>
        <AudioFormat>MXF</AudioFormat>
        <SamplingRate>48000</SamplingRate>
        <BitsPerSample>16</BitsPerSample>
        <AudioIndex>
          <StartByteOffset>32768</StartByteOffset>
          <DataSize>6880472</DataSize>
        </AudioIndex>
      </Audio>
      <Audio>
        <AudioFormat>MXF</AudioFormat>
        <SamplingRate>48000</SamplingRate>
        <BitsPerSample>16</BitsPerSample>
        <AudioIndex>
          <StartByteOffset>32768</StartByteOffset>
          <DataSize>6880472</DataSize>
        </AudioIndex>
      </Audio>
      <Audio>
        <AudioFormat>MXF</AudioFormat>
        <SamplingRate>48000</SamplingRate>
        <BitsPerSample>16</BitsPerSample>
        <AudioIndex>
          <StartByteOffset>32768</StartByteOffset>
          <DataSize>6880472</DataSize>
        </AudioIndex>
      </Audio>
    </EssenceList>
    <ClipMetadata>
      <UserClipName>060A2B340101010501010D431300000021E314B9117805CB0080458250D62215</UserClipName>
      <DataSource>SHOOTING</DataSource>
      <Access>
        <CreationDate>2017-02-27T17:58:10+00:00</CreationDate>
        <LastUpdateDate>2017-02-27T17:59:22+00:00</LastUpdateDate>
      </Access>
      <Device>
        <Manufacturer>Panasonic</Manufacturer>
        <SerialNo.>F8TS00022</SerialNo.>
        <ModelName>AG-HPX500P</ModelName>
      </Device>
      <Shoot>
        <StartDate>2017-02-27T17:58:11+00:00</StartDate>
        <EndDate>2017-02-27T17:59:22+00:00</EndDate>
      </Shoot>
      <Thumbnail>
        <FrameOffset>0</FrameOffset>
        <ThumbnailFormat>BMP</ThumbnailFormat>
        <Width>80</Width>
        <Height>60</Height>
      </Thumbnail>
    </ClipMetadata>
  </ClipContent>
</P2Main>

这是我的样式表。

<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:soa="urn:telestream.net:soa:core" exclude-result-prefixes="soa" >
  <xsl:output method="xml" indent="yes" encoding="utf-8" />
  <xsl:template match="/">
    <soa:Label>
      <soa:Parameter type="string" identifier="089f7368-6930-47d6-9083-4344735249b9" bindable="True" name="P2 Clip Name" enabled="true" enabledinvariants="true" disableable="false" browsable="true" optionseditable="false" row="-1" column="-1" columnspan="1">
        <xsl:value-of select="P2Main/ClipContent/ClipName/text()"/>
        <soa:IsRequired>false</soa:IsRequired>
      </soa:Parameter>
      <soa:Parameter type="string" identifier="ac49728d-879d-4702-824e-2d33065e6e9f" bindable="True" name="P2 Offset" enabled="true" enabledinvariants="true" disableable="false" browsable="true" optionseditable="false" row="-1" column="-1" columnspan="1">
        <xsl:value-of select="P2Main/ClipContent/Relation/OffsetInShot/text()"/>
        <soa:IsRequired>false</soa:IsRequired>
      </soa:Parameter>
      <soa:Parameter type="string" identifier="68ef76d9-609f-4376-a5fe-ded6ff6c92de" bindable="True" name="P2 top clip" enabled="true" enabledinvariants="true" disableable="false" browsable="true" optionseditable="false" row="-1" column="-1" columnspan="1">
        <xsl:value-of select="P2Main/ClipContent/Relation/Connection/Top/ClipName/text()"/>
        <soa:IsRequired>false</soa:IsRequired>
      </soa:Parameter>
      <soa:Parameter type="string" identifier="0f33fea3-7807-4c8a-b70a-0be05900c74f" bindable="True" name="P2 next clip" enabled="true" enabledinvariants="true" disableable="false" browsable="true" optionseditable="false" row="-1" column="-1" columnspan="1">
        <xsl:value-of select="P2Main/ClipContent/Relation/Connection/Next/ClipName/text()"/>
        <soa:IsRequired>false</soa:IsRequired>
      </soa:Parameter>
      <soa:Parameter type="string" identifier="c4444524-189d-4117-9d53-a8ecd0518014" bindable="True" name="P2 previous clip" enabled="true" enabledinvariants="true" disableable="false" browsable="true" optionseditable="false" row="-1" column="-1" columnspan="1">
        <xsl:value-of select="P2Main/ClipContent/Relation/Connection/Previous/ClipName/text()"/>
        <soa:IsRequired>false</soa:IsRequired>
      </soa:Parameter>
    </soa:Label>
  </xsl:template>
</xsl:stylesheet>

正确解析(到目前为止)解析的唯一方法是删除 xmlns:xsi =“http://www.w3.org/2001/XMLSchema-instance”xmlns =“urn:schemas-Professional -Plug-in:P2:ClipMetadata:v3.0“来自<P2Main>标题,但这不起作用,因为我必须自动对每个P2 XML文件执行此操作。

关于我做错了什么/遗失的任何想法?

谢谢

0 个答案:

没有答案