Ich bin neu zu schreiben XSL-Transformationen zu ermöglichen, und ich versuche, eine XSL zu erstellen, die ein bestimmtes Format von XML deckt Ich habe zwei excamples hier:versuchen, eine generische XSL zu schaffen für etwas anderen XML-Formate
<?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 [email protected]</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>[email protected]</ContactEmail>
</ContactInformation>
</Technical>
</Programme>
die zweite wird hier gezeigt:
<?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 [email protected]</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>[email protected]</ContactEmail><ContactTelephoneNumber>01413003000</ContactTelephoneNumber></ContactInformation></Technical></Programme>
ich versuche, die Gesamtzahl der Teile zu extrahieren, sondern eine einzige XSL möchten, die für beide funktionieren. Ich habe es geschafft, einen zu bekommen, der für jeden einzelnen unten gezeigten funktioniert, aber es scheint, dass ihr XPATH für beide unterschiedlich ist, wo man seinen Präfix während des gesamten XPATH benötigt und der andere nicht. Offensichtlich besteht das andere Problem darin, dass ihre Namespaces leicht unterschiedlich sind. Kann man das auch erklären?
<?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>
Die zweite XSL ist hier:
<?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>
Just So, zu klären, ist es eine Möglichkeit, eine einzelne XSL schreiben die Anzahl der Teile von beiden XML zu extrahieren ist also egal, welche XML war die Quelle würde die Transformation an beiden arbeiten?
Much
geschätzt