所以我需要在下面用XML创建一个新的XML文件。我对tokenize values.ll
有疑问,并将值与<TitlePack id.l="15241" />, <TitlePack id.l="....." />
<Pack>
<titlesPacks t="lt">
<TitlePack id.l="12120" guid.s="570ff1a9-6522-4c0d-8f6e-f0580b8cbc2a">
<assets t="t">
<TitleAssets>
<assets t="lt">
<LongAssetInfoMulti attrTagName.s="WEB_Slika_internet" attrName.s="WEB_Slika_internet" values.ll="15241 14553 15239"/>
</assets>
</TitleAssets>
</assets>
</TitlePack>
<TitlePack id.l="15241" guid.s="2f178e74-c2f7-4551-8ce2-35661dc119e3">
<title t="t">
<Title modifiedBy.s="1" mainStatus.s="New" soundFileName.s="\\Pilotshare\Storage\Images\00004313.jpg" endDate.td="2014-11-22T12:57:39.120" composer.s="" lastModifTime.td="2013-11-22T12:57:39.163" isAversion.l="0" year.td="2013-11-22T12:57:39.120" frameRate.l="0" industry.l="0" itemCode.s="LP_2959" topic.s="" useManualDuration.l="0" albumName.s="" keywordsComment.s=" " createdBy.s="1" frames.l="0" oeuvre.s="" language.s="Slovenian" versionNumber.l="-1" startDate.td="2013-11-22T12:57:39.120" is_rotational_cart.l="0" fadeOut.tp="P0:0:0.000S" isRecorded.l="0" folderId.s="417" isOnline.l="1" labelReference.s="" recordDate.td="2013-11-22T12:57:39.120" createdAt.td="2013-11-22T12:57:39.163" soundFileId.s="17171" languageId.l="187" intro.tp="P0:0:0.000S" medium.l="0" product.l="0" folderName.s="IMAGES" titlePeriod.s="" cut.s="" custom1.s="" replacement.s="" custom2.s="" client.s="" mediaProcessStatus.l="9" interfaceId.l="0" modifiedByName.s="ADMIN" compagnyDispName.s="" type.l="9" soundUnitId.s="3" endOffset.tp="P0:0:0.000S" readRate.l="0" fadeIn.tp="P0:0:0.000S" status.l="0" reader.l="0" titleVersion.s="1" crossfade.tp="P0:0:0.000S" soundUnitName.s="Images" lastWords.s="" voice.s="" modifiedAt.td="2013-11-22T12:57:39.163" yearComposed.td="1899-12-31T23:00:00.000" frameScale.l="0" orchestra.s="" interpretComment.s=" " creator.s="" Id.s="15241" author.s="" no_overwrite.l="0" createdByName.s="ADMIN" name.s="have-love-1" killDate.td="2015-11-22T12:57:39.120" conductor.s="" duration.tp="P533:11:43.676S" beginOffset.tp="P0:0:0.000S" source.s="" manualDuration.tp="P0:0:0.000S" volumeNumber.s="" act.s="">
</Title>
</title>
</TitlePack>
<TitlePack id.l="14451" guid.s="25886d69-736e-4143-a6d4-1d5affde79d2">
<title t="t">
<Title modifiedBy.s="1" mainStatus.s="New" soundFileName.s="\\Pilotshare\Storage\Images\00004005.jpg" endDate.td="2013-12-17T10:19:55.077" composer.s="" lastModifTime.td="2013-06-07T08:35:56.223" isAversion.l="0" year.td="2012-12-17T10:19:55.077" frameRate.l="0" industry.l="0" itemCode.s="LP_2725" topic.s="" useManualDuration.l="0" albumName.s="" keywordsComment.s=" " createdBy.s="1" frames.l="0" oeuvre.s="" language.s="Slovenian" versionNumber.l="-1" startDate.td="2012-12-17T10:19:55.077" is_rotational_cart.l="0" fadeOut.tp="P0:0:0.000S" isRecorded.l="0" folderId.s="417" isOnline.l="1" labelReference.s="" recordDate.td="2012-12-17T10:19:55.077" createdAt.td="2012-12-17T10:19:54.670" soundFileId.s="16389" languageId.l="187" intro.tp="P0:0:0.000S" medium.l="0" product.l="0" folderName.s="IMAGES" titlePeriod.s="" cut.s="" custom1.s="" replacement.s="" custom2.s="" client.s=" ADMIN" mediaProcessStatus.l="9" interfaceId.l="0" modifiedByName.s="ADMIN" compagnyDispName.s="" type.l="9" soundUnitId.s="3" endOffset.tp="P0:0:0.000S" readRate.l="0" fadeIn.tp="P0:0:0.000S" status.l="0" reader.l="0" titleVersion.s="1" crossfade.tp="P0:0:0.000S" soundUnitName.s="Images" lastWords.s="" voice.s="" modifiedAt.td="2013-06-07T08:35:56.223" yearComposed.td="1899-12-31T23:00:00.000" frameScale.l="0" orchestra.s="" interpretComment.s=" " creator.s="" Id.s="14451" author.s="Bobo" no_overwrite.l="0" createdByName.s="ADMIN" name.s="Lighthouse" killDate.td="2014-12-17T10:19:55.077" conductor.s="" duration.tp="P0:0:0.000S" beginOffset.tp="P0:0:0.000S" source.s="" manualDuration.tp="P0:0:0.000S" volumeNumber.s="" act.s="">
</Title>
</title>
</TitlePack>
<TitlePack id.l="15239" guid.s="3dc41a6e-7011-4bd4-be01-8de04d883808">
<title t="t">
<Title modifiedBy.s="1" mainStatus.s="New" soundFileName.s="\\Pilotshare\Storage\Images\00004311.tif" endDate.td="2014-11-22T12:29:47.270" composer.s="" lastModifTime.td="2013-11-22T12:29:47.397" isAversion.l="0" year.td="2013-11-22T12:29:47.270" frameRate.l="0" industry.l="0" itemCode.s="LP_2957" topic.s="" useManualDuration.l="0" albumName.s="" keywordsComment.s=" " createdBy.s="1" frames.l="0" oeuvre.s="" language.s="Slovenian" versionNumber.l="-1" startDate.td="2013-11-22T12:29:47.270" is_rotational_cart.l="0" fadeOut.tp="P0:0:0.000S" isRecorded.l="0" folderId.s="417" isOnline.l="1" labelReference.s="" recordDate.td="2013-11-22T12:29:47.270" createdAt.td="2013-11-22T12:29:47.287" soundFileId.s="17169" languageId.l="187" intro.tp="P0:0:0.000S" medium.l="0" product.l="0" folderName.s="IMAGES" titlePeriod.s="" cut.s="" custom1.s="" replacement.s="" custom2.s="" client.s=" ADMIN" mediaProcessStatus.l="9" interfaceId.l="0" modifiedByName.s="ADMIN" compagnyDispName.s="" type.l="9" soundUnitId.s="3" endOffset.tp="P0:0:0.000S" readRate.l="0" fadeIn.tp="P0:0:0.000S" status.l="0" reader.l="0" titleVersion.s="1" crossfade.tp="P0:0:0.000S" soundUnitName.s="Images" lastWords.s="" voice.s="" modifiedAt.td="2013-11-22T12:29:47.397" yearComposed.td="1899-12-31T23:00:00.000" frameScale.l="0" orchestra.s="" interpretComment.s=" " creator.s="" Id.s="15239" author.s=" ADMIN" no_overwrite.l="0" createdByName.s="ADMIN" name.s="pek2_02" killDate.td="2015-11-22T12:29:47.270" conductor.s="" duration.tp="P0:0:0.000S" beginOffset.tp="P0:0:0.000S" source.s="" manualDuration.tp="P0:0:0.000S" volumeNumber.s="" act.s="">
</Title>
</title>
</TitlePack>
</titlesPacks>
我需要这样的结果:
<content>
<item>
<WEB_Slika_internet>
<Title>
<soundFileName.s>\\Pilotshare\Storage\Images\00004313.jpg</soundFileName.s>
</Title>
</WEB_Slika_internet>
<WEB_Slika_internet>
<Title>
<soundFileName.s>\\Pilotshare\Storage\Images\00004005.jpg</soundFileName.s>
</Title>
</WEB_Slika_internet>
<WEB_Slika_internet>
<Title>
<soundFileName.s>\\Pilotshare\Storage\Images\00004311.tif</soundFileName.s>
</Title>
</WEB_Slika_internet>
</item>
所以我在values.ll
标记
LongAssetInfoMulti
中进行比较
<Pack>
<titlesPacks t="lt">
<TitlePack id.l="12120" guid.s="570ff1a9-6522-4c0d-8f6e-f0580b8cbc2a">
<assets t="t">
<TitleAssets>
<assets t="lt">
<LongAssetInfoMulti attrTagName.s="WEB_Slika_internet" attrName.s="WEB_Slika_internet" values.ll="15241 14553 15239"/>
</assets>
</TitleAssets>
</assets>
</TitlePack>
</titlesPacks>
从标记id.l
TitlePack
<Pack>
<titlesPacks t="lt">
<TitlePack id.l="12120" guid.s="570ff1a9-6522-4c0d-8f6e-f0580b8cbc2a" />
<TitlePack id.l="15241" guid.s="2f178e74-c2f7-4551-8ce2-35661dc119e3" />
<TitlePack id.l="14451" guid.s="25886d69-736e-4143-a6d4-1d5affde79d2" />
<TitlePack id.l="15239" guid.s="3dc41a6e-7011-4bd4-be01-8de04d883808" />
</titlesPacks>
如果它们与标记soundFileName.s
具有相同的写属性Title
(或每个属性)。
如果您有任何想法如何将标记化属性与其他属性进行比较并使用XSLT将其写入新XML,请提供帮助。
那是我的xsl:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="Pack/titlesPacks/TitlePack">
<xsl:variable name="list" select="/assets/TitleAssets/assets/LongAssetInfoMulti/@values.ll" />
<xsl:variable name="item" select="/@id.l" />
<xsl:choose>
<xsl:when test="contains(concat(' ', $list, ' '), concat(' ', $item, ' '))">
<xsl:element name="WEB_Slika_internet">
<xsl:value-of select="/title/Title/@soundFileName.s"></xsl:value-of>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:template>
但我明白了:
<?xml version="1.0" encoding="UTF-8"?><WEB_Slika_internet></WEB_Slika_internet><WEB_Slika_internet></WEB_Slika_internet>
有任何新想法吗?
答案 0 :(得分:1)
没有必要对属性进行标记。您可以通过以下方式测试给定项目是否出现在以空格分隔的列表中:
<xsl:if test="contains(concat(' ', $list, ' '), concat(' ', $item, ' '))">
当然,如果您的处理器支持XSLT 2.0或EXSLT str:tokenize()扩展函数,则与标记化值的比较更为直接。