gpt4 book ai didi

xml - 尝试创建通用 XSL 以允许稍微不同的 XML 格式

转载 作者:行者123 更新时间:2023-12-03 16:16:19 25 4
gpt4 key购买 nike

我是编写 XSL 转换的新手,我正在尝试创建一个涵盖特定 XML 格式的 XSL 我在这里有两个例子:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Programme xmlns="http://www.digitalproductionpartnership.co.uk/ns/as11/2012">
<Editorial xmlns="">
<SeriesTitle>Paul And Nicks Big American Food Trip Series 2</SeriesTitle>
<ProgrammeTitle>Paul And Nicks Big American Food Trip</ProgrammeTitle>
<EpisodeTitleNumber>Washington DC</EpisodeTitleNumber>
<ProductionNumber>PRG86396_1</ProductionNumber>
<Synopsis>Paul and Nick visit Washington DC to cook up an Ulster Scots meal for their guests.</Synopsis>
<Originator>Waddell Media</Originator>
<CopyrightYear>2015</CopyrightYear>
</Editorial>
<Technical xmlns="">
<ShimName>DPP V4.1 HD AVC-I AS-11</ShimName>
<Video>
<PictureFormat>1080i50 16:9</PictureFormat>
<AFD>10</AFD>
<PictureRatio>16:9 (1.78:1)</PictureRatio>
<ProductPlacement>false</ProductPlacement>
<VideoComments>
</VideoComments>
<VideoBitRate unit="Mbps">100</VideoBitRate>
<VideoCodecParameters>High 4:2:2 Intra@L4.1</VideoCodecParameters>
</Video>
<Audio>
<PrimaryAudioLanguage>eng</PrimaryAudioLanguage>
<SecondaryAudioLanguage>zxx</SecondaryAudioLanguage>
<TertiaryAudioLanguage>zxx</TertiaryAudioLanguage>
<AudioLoudnessStandard>_UKDPP_AUDIO_LOUDNESS_STANDARD_EBU_R_128</AudioLoudnessStandard>
<AudioComments>
</AudioComments>
</Audio>
<Timecodes>
<LineUpStart>09:58:00:00</LineUpStart>
<IdentClockStart>09:59:30:00</IdentClockStart>
<Parts>
<Part>
<PartNumber>1</PartNumber>
<PartTotal>3</PartTotal>
<PartSOM>10:00:00:00</PartSOM>
<PartDuration>00:10:46:00</PartDuration>
</Part>
<Part>
<PartNumber>2</PartNumber>
<PartTotal>3</PartTotal>
<PartSOM>10:12:00:00</PartSOM>
<PartDuration>00:11:34:00</PartDuration>
</Part>
<Part>
<PartNumber>3</PartNumber>
<PartTotal>3</PartTotal>
<PartSOM>10:24:38:15</PartSOM>
<PartDuration>00:00:20:20</PartDuration>
</Part>
</Parts>
<TotalNumberOfParts>3</TotalNumberOfParts>
<TotalProgrammeDuration>00:22:40:20</TotalProgrammeDuration>
</Timecodes>
<AccessServices>
<SigningPresent>No</SigningPresent>
<OpenCaptionsPresent>
</OpenCaptionsPresent>
</AccessServices>
<AdditionalNode>
<TextlessElementsExist>True</TextlessElementsExist>
<CompletionDate>11/02/2016 17:47:42</CompletionDate>
<ProgrammeHasText>eng</ProgrammeHasText>
</AdditionalNode>
<ContactInformation>
<ContactEmail>mikemcg@waddellmedia.com</ContactEmail>
</ContactInformation>
</Technical>
</Programme>

第二个在这里显示:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Programme xmlns="http://www.digitalproductionpartnership.co.uk/ns/as11/2015"><Editorial><SeriesTitle>ART</SeriesTitle><ProgrammeTitle>Ep26 Col safe test</ProgrammeTitle><EpisodeTitleNumber>Ep26</EpisodeTitleNumber><ProductionNumber>FKRD991W/01</ProductionNumber><Synopsis>James and Charlie</Synopsis><Originator>STV Productions</Originator><CopyrightYear>2016</CopyrightYear></Editorial><Technical><ShimName>UK DPP HD</ShimName><ShimVersion>1.1</ShimVersion><Video><VideoBitRate unit="Mbps">100</VideoBitRate><VideoCodec>AVC-Intra 100</VideoCodec><VideoCodecParameters>High 4:2:2 Intra@L4.1</VideoCodecParameters><PictureFormat>1080i50 16:9</PictureFormat><AFD>10</AFD><PictureRatio>16:9 (1.78:1)</PictureRatio><ThreeD>false</ThreeD><ProductPlacement>false</ProductPlacement><PSEPass>Yes</PSEPass><PSEManufacturer>Ofcom</PSEManufacturer><PSEVersion>2009</PSEVersion></Video><Audio><AudioSamplingFrequency unit="kHz">48</AudioSamplingFrequency><AudioBitDepth>24</AudioBitDepth><AudioCodecParameters>PCM</AudioCodecParameters><AudioTrackLayout>EBU R 48: 2a</AudioTrackLayout><PrimaryAudioLanguage>eng</PrimaryAudioLanguage><SecondaryAudioLanguage>zxx</SecondaryAudioLanguage><TertiaryAudioLanguage>zxx</TertiaryAudioLanguage><AudioLoudnessStandard>EBU R 128</AudioLoudnessStandard></Audio><Timecodes><LineUpStart>09:59:30:00</LineUpStart><IdentClockStart>09:59:50:00</IdentClockStart><Parts><Part><PartNumber>1</PartNumber><PartTotal>1</PartTotal><PartSOM>10:00:00:00</PartSOM><PartDuration>00:05:25:10</PartDuration></Part></Parts><TotalNumberOfParts>2</TotalNumberOfParts><TotalProgrammeDuration>00:05:25:10</TotalProgrammeDuration></Timecodes><AccessServices><AudioDescriptionPresent>false</AudioDescriptionPresent><ClosedCaptionsPresent>false</ClosedCaptionsPresent><OpenCaptionsPresent>false</OpenCaptionsPresent><SigningPresent>No</SigningPresent></AccessServices><Additional><CompletionDate>2016-01-11</CompletionDate><TextlessElementsExist>false</TextlessElementsExist><ProgrammeHasText>true</ProgrammeHasText><ProgrammeTextLanguage>eng</ProgrammeTextLanguage><AssociatedMediaFilename>Ep26 Col safe test.mxf</AssociatedMediaFilename><MediaChecksumType>MD5</MediaChecksumType><MediaChecksumValue></MediaChecksumValue></Additional><ContactInformation><ContactEmail>lucy.austin@stv.tv</ContactEmail><ContactTelephoneNumber>01413003000</ContactTelephoneNumber></ContactInformation></Technical></Programme>

我正在尝试提取部分的总数,但想要一个对两者都适用的 XSL。我设法得到一个适用于下面显示的每个单独的,但似乎它们的 XPATH 对两者都不同,其中一个需要通过 XPATH 的前缀,而另一个不需要。显然另一个问题是他们的命名空间略有不同,有没有办法解决这个问题?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="//edx:Programme" xmlns:edx="http://www.digitalproductionpartnership.co.uk/ns/as11/2012"><xsl:value-of select="/edx:Programme/Technical/Timecodes/TotalNumberOfParts" /></xsl:template>
</xsl:stylesheet>

第二个 XSL 在这里:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="//edx:Programme" xmlns:edx="http://www.digitalproductionpartnership.co.uk/ns/as11/2015"><xsl:value-of select="/edx:Programme/edx:Technical/edx:Timecodes/edx:TotalNumberOfParts" /></xsl:template>
</xsl:stylesheet>

所以,只是为了澄清一下,是否有一种方法可以编写单个 XSL 来从两个 XML 中提取部分数量,因此无论哪个 XML 是源,转换都适用于两者?

非常感激

最佳答案

如果将所写的两个模板(在 xsl:template 上带有本地 namespace 声明)放入单个样式表中,那么 XSLT 处理器将应用与输入格式匹配的模板。

关于xml - 尝试创建通用 XSL 以允许稍微不同的 XML 格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36102632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com