처음으로 질문을 올리므로 잘못 입력하면 사과드립니다. . 본질적으로 내가 시도하는 것은 XSLT를 사용하여 XML로부터 XML을 생성하는 것이다. 온라인에서 예제를 참조하려고했지만 비슷한 것을 찾을 수 없었습니다. 나는 3 가지 주요 단계로 세분화 할 수 노력하고 무엇 :XSLT to XML - XML의 일부분을 파싱합니다 (주요 출력 문제)
3 별도의 방법에 대한 템플릿을 설정. 생성, 업데이트 및 제거. 생성 및 업데이트는 XML 을 변환하기위한 일부 논리가 필요하지만 Purge 메서드는 XML을 통해 구문 분석합니다.
PromoMessage 태그에서 배포 종료 태그까지의 XML 부분을 구문 분석합니다.
실제로 참조하는 태그의 값을 포함하도록 XML에 출력되는 필드. 이 논리를 사용하여 참조되어야 하나는, 상기 방법은 삽입 카테고리 및 홍보 프로그램의 종류를 선택하는 로직을 필요로하는 가장 복잡한 소스 생성된다
자료 :
여기 소스 XMLS의 두 가지 예 .
<?xml version="1.0" ?>
<PromoMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Header origin="IBMSV6" method="create" timestamp="2013-08-06T06:32:17Z" />
<Body>
<CreatePromo providerId="NJR" promoID="245686_NJ01858S ">
<Distribution>
<RightsWindow start="2013-07-31T14:00:00Z" end="2013-08-31T13:59:59Z" />
<Destinations>
<Destination platform="WCMS" site="EPG" visible="true">
<DisplayWindow start="2013-07-31T14:00:00Z" end="2013-08-31T13:59:59Z" />
</Destination>
</Destinations>
</Distribution>
<Interstitial category= "episodic" multi_prog="false" name="Promo Alpha" parentalRating ="PG" >
<PromotedProgramme type ="MovieOrEvent" seq_number ="1" > //promoted prog non-series
<TitleId>000000218564</TitleId>
<ExternalProgId>785432</ExternalProgId>
<TitleBroadcastRef>078654</TitleBroadcastRef>
<TitleName>Men In Black</TitleName>
</PromotedProgramme>
<PromotedProgramme type ="MoviefssOrEvent" seq_number ="2"> <!--promoted slot non-series-->
<SlotId>675342</SlotId>
<SlotName>Late Movie</SlotName>
<TitleId>000000218576</TitleId>
<ExternalProgId>785632</ExternalProgId>
<TitleBroadcastRef>078123</TitleBroadcastRef>
<TitleName>Die Hard</TitleName>
<EPGTitleName>Die Hard</EPGTitleName>
</PromotedProgramme>
<PromotedProgramme type ="Series" seq_number ="3"> <!--promoted prog series-->
<TitleId>000000218321</TitleId>
<ExternalProgId>785122</ExternalProgId>
<TitleBroadcastRef>075432</TitleBroadcastRef>
<TitleName> Friends S5 Ep5</TitleName>
<EpisodeNo>10</EpisodeNo>
<SeasonId>10645346</SeasonId>
<SeasonName>Friends</SeasonName>
<SeasonNo>5</SeasonNo>
<SeasonYear>5</SeasonYear>
<ShowId>10987532</ShowId>
<ShowName>Friends</ShowName>
<EPGTitleName>Friends</EPGTitleName>
</PromotedProgramme>
<PromotedProgramme type ="Slot" seq_number ="4"> <!--promoted slot - no prog or title assigned to slot-->
<SlotId>675347</SlotId>
<SlotName>Late Movie</SlotName>
</PromotedProgramme>
<PromotedProgramme type ="ExtChannel" seq_number ="5"> <!--promoted prog from ext.channel-->
<PromotedBroadcastRef>675347</PromotedBroadcastRef >
</PromotedProgramme>
</Interstitial>
<Media>
<Source>playout</Source>
<Identifier>NJ01858S </Identifier>
<AspectRatio>16X9 </AspectRatio>
</Media>
</CreatePromo>
</Body>
</PromoMessage>
은 소스 2가 퍼지 요청입니다 그냥 방법에 따라를 통해 분석 할 필요가 :
: 여기- <PromoMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Header origin="IBMSV6" method="purge" timestamp="2013-08-06T06:34:07Z" />
- <Body>
- <PurgePromo providerId="NJR" promoID="245685_NJ01857S">
- <Distribution>
- <Destinations>
<Destination platform="WCMS" site="EPG" />
</Destinations>
</Distribution>
</PurgePromo>
</Body>
</PromoMessage>
내 현재 XSLT입니다 업데이트 방법은 같은 방식으로 작동합니다
<?xml version="1.0" encoding="UTF-8"?>
<PromoMessage xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Header origin="" method=" //promoted prog non-series
 000000218564785432078654Men In Black675342Late Movie000000218576785632078123Die HardDie Hard000000218321785122075432 Friends S5 Ep51010645346Friends5510987532FriendsFriends675347Late Movie675347playoutNJ01858S 16X9 " timestamp=" //promoted prog non-series
 000000218564785432078654Men In Black675342Late Movie000000218576785632078123Die HardDie Hard000000218321785122075432 Friends S5 Ep51010645346Friends5510987532FriendsFriends675347Late Movie675347playoutNJ01858S 16X9 "/>
<Body>
<CreatePromo providerId="" promoID="">
<Distribution>
<RightsWindow start="" end=""/>
<Destinations>
<Destination platform="" site="" visible="">
<DisplayWindow start="" end=""/>
</Destination>
</Destinations>
</Distribution>
<EventLink type="" title="" parentalRating="">
<Programme>
<ProgrammeId></ProgrammeId>
</Programme>
</EventLink>
<Media>
<Source>
<Videos>
<Video source="" Identifier="" aspect_ratio=""/>
</Videos>
</Source>
</Media>
</CreatePromo>
</Body>
</PromoMessage>
01 : 여기
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<!--xsl:template match="PromoMessage/Header[@method]='purge'"/-->
<PromoMessage>
<!--xsl:variable name="origin"/>
<xsl:variable name="method"/>
<xsl:variable name="timestamp"/>
<xsl:variable name="providerId"/>
<xsl:variable name="promoID"/>
<xsl:variable name="RWstart"/>
<xsl:variable name="RWend"/>
<xsl:variable name="platform"/>
<xsl:variable name="site"/>
<xsl:variable name="visible"/>
<xsl:variable name="DWstart"/>
<xsl:variable name="DWend"/-->
<Header>
<xsl:apply-templates select="PromoMessage/Header"/>
<xsl:attribute name="origin">
<xsl:value-of select="PromoMessage/Header[@origin]"/>
</xsl:attribute>
<!--xsl:variable name="method">
<xsl:if test="PromoMessage/Header[@method]='create' or 'update'"></xsl:if>
<xsl:if test="PromoMessage/Header[@method]='purge'"></xsl:if>
</xsl:variable-->
<xsl:attribute name="method">
<xsl:value-of select="/"/>
</xsl:attribute>
<xsl:attribute name="timestamp">
<xsl:value-of select="/"/>
</xsl:attribute>
</Header>
<Body>
<xsl:apply-templates select="PromoMessage/Header/Body"/>
<CreatePromo>
<xsl:attribute name="providerId">
<xsl:value-of select="@providerId"/>
</xsl:attribute>
<xsl:attribute name="promoID">
<xsl:value-of select="@promoID"/>
</xsl:attribute>
<Distribution>
<RightsWindow>
<xsl:attribute name="start">
<xsl:value-of select="@start"/>
</xsl:attribute>
<xsl:attribute name="end">
<xsl:value-of select="@end"/>
</xsl:attribute>
</RightsWindow>
<Destinations>
<Destination>
<xsl:attribute name="platform">
<xsl:value-of select="@platform"/>
</xsl:attribute>
<xsl:attribute name="site">
<xsl:value-of select="@site"/>
</xsl:attribute>
<xsl:attribute name="visible" >
<xsl:value-of select="@visible"/>
</xsl:attribute>
<DisplayWindow>
<xsl:attribute name="start">
<xsl:value-of select="@start"/>
</xsl:attribute>
<xsl:attribute name="end">
<xsl:value-of select="@end"/>
</xsl:attribute>
</DisplayWindow>
</Destination>
</Destinations>
</Distribution>
<EventLink>
<xsl:choose>
<!--Interstitial Category episodic & Promoted Programme Type MovieOrEvent-->
<xsl:when test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme/@type='MovieOrEvent'">
<xsl:attribute name="type">
<xsl:value-of select="@category"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='MovieOrEvent']/EPGTitleName != '0'">
<xsl:value-of select="EPGTitleName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='MovieOrEvent']/TitleName != '0'">
<xsl:value-of select="TitleName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='MovieOrEvent']/SlotName != '0'">
<xsl:value-of select="SlotName"/>
</xsl:if>
</xsl:attribute>
<xsl:attribute name="parentalRating">
<xsl:value-of select="@parentalRating"/>
</xsl:attribute>
<Programme>
<ProgrammeId>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='MovieOrEvent']/ExternalProgId != '0'">
<xsl:value-of select ="ExternalProgId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='MovieOrEvent']/TitleId != '0'">
<xsl:value-of select ="TitleId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='MovieOrEvent']/SlotId != '0'">
<xsl:text>S</xsl:text><xsl:value-of select ="SlotId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='MovieOrEvent']/PromotedBroadcastRef != '0'">
<xsl:value-of select ="PromotedBroadcastRef"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='MovieOrEvent']/TitleBroadcastRef != '0'">
<xsl:value-of select ="TitleBroadcastRef"/></xsl:if>
</ProgrammeId>
</Programme>
</xsl:when>
<!--Interstitial Category episodic & Promoted Programme Type Series-->
<xsl:when test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme/@type='Series'">
<xsl:attribute name="type">
<xsl:value-of select="@category"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Series']/EPGTitleName != '0'">
<xsl:value-of select="EPGTitleName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Series']/SeasonName != '0'">
<xsl:value-of select="SeasonName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Series']/TitleName != '0'">
<xsl:value-of select="TitleName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Series']/SlotName != '0'">
<xsl:value-of select="SlotName"/>
</xsl:if>
</xsl:attribute>
<xsl:attribute name="parentalRating">
<xsl:value-of select="@parentalRating"/>
</xsl:attribute>
<Programme>
<ProgrammeId>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Series']/ExternalProgId != '0'">
<xsl:value-of select ="ExternalProgId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Series']/TitleId != '0'">
<xsl:value-of select ="TitleId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Series']/SlotId != '0'">S
<xsl:value-of select ="SlotId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Series']/PromotedBroadcastRef != '0'">
<xsl:value-of select ="PromotedBroadcastRef"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Series']/TitleBroadcastRef != '0'">
<xsl:value-of select ="TitleBroadcastRef"/></xsl:if>
</ProgrammeId>
</Programme>
</xsl:when>
<!--Interstitial Category episodic & Promoted Programme Type Slot-->
<xsl:when test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme/@type='Slot'">
<xsl:attribute name="type">
<xsl:value-of select="@category"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Slot']/EPGTitleName != '0'">
<xsl:value-of select="EPGTitleName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Slot']/SeasonName != '0'">
<xsl:value-of select="SeasonName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Slot']/TitleName != '0'">
<xsl:value-of select="TitleName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Slot']/SlotName != '0'">
<xsl:value-of select="SlotName"/>
</xsl:if>
</xsl:attribute>
<xsl:attribute name="parentalRating">
<xsl:value-of select="@parentalRating"/>
</xsl:attribute>
<Programme>
<ProgrammeId>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Slot']/ExternalProgId != '0'">
<xsl:value-of select ="ExternalProgId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Slot']/TitleId != '0'">
<xsl:value-of select ="TitleId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Slot']/SlotId != '0'">S
<xsl:value-of select ="SlotId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Slot']/PromotedBroadcastRef != '0'">
<xsl:value-of select ="PromotedBroadcastRef"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='Slot']/TitleBroadcastRef != '0'">
<xsl:value-of select ="TitleBroadcastRef"/></xsl:if>
</ProgrammeId>
</Programme>
</xsl:when>
<!--Interstitial Category episodic & Promoted Programme Type ExtChannel-->
<xsl:when test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme/@type='ExtChannel'">
<xsl:attribute name="type">
<xsl:value-of select="@category"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='ExtChannel']/EPGTitleName != '0'">
<xsl:value-of select="EPGTitleName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='ExtChannel']/SeasonName != '0'">
<xsl:value-of select="SeasonName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='ExtChannel']/TitleName != '0'">
<xsl:value-of select="TitleName"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='ExtChannel']/SlotName != '0'">
<xsl:value-of select="SlotName"/>
</xsl:if>
</xsl:attribute>
<xsl:attribute name="parentalRating">
<xsl:value-of select="@parentalRating"/>
</xsl:attribute>
<Programme>
<ProgrammeId>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='ExtChannel']/ExternalProgId != '0'">
<xsl:value-of select ="ExternalProgId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='ExtChannel']/TitleId != '0'">
<xsl:value-of select ="TitleId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='ExtChannel']/SlotId != '0'">S
<xsl:value-of select ="SlotId"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='ExtChannel']/PromotedBroadcastRef != '0'">
<xsl:value-of select ="PromotedBroadcastRef"/></xsl:if>
<xsl:if test="PromoMessage/Body/CreatePromo/Interstitial[@category='episodic']/PromotedProgramme[@type='ExtChannel']/TitleBroadcastRef != '0'">
<xsl:value-of select ="TitleBroadcastRef"/></xsl:if>
</ProgrammeId>
</Programme>
</xsl:when>
</xsl:choose>
<Media>
<Source>
<Videos>
<Video>
<xsl:attribute name="source">
<xsl:value-of select="@Source"/>
</xsl:attribute>
<xsl:attribute name="Identifier">
<xsl:value-of select="@Identifier"/>
</xsl:attribute>
<xsl:attribute name="aspect_ratio">
<xsl:value-of select="@AspectRatio"/>
</xsl:attribute>
</Video>
</Videos>
</Source>
</Media>
</CreatePromo>
</Body>
</PromoMessage>
</xsl:template>
</xsl:stylesheet>
는 소스 1 XML을 사용하여 XSLT의 출력 인 누군가가 올바른 방향으로 날 지점 수 있다면 확실히, 감사 감사하겠습니다
<?xml version="1.0" ?>
- <PromoMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Header origin="IBMSV6" method="create" timestamp="2013-08-06T06:32:17Z" />
<Body>
<CreatePromo providerId="NJR" promoID="245686_NJ01858S">
<Distribution>
<RightsWindow start="2013-07-31T14:00:00Z" end="2013-08-31T13:59:59Z" />
<Destinations>
<Destination platform="WCMS" site="EPG" visible="true">
<DisplayWindow start="2013-07-31T14:00:00Z" end="2013-08-31T13:59:59Z" />
</Destination>
</Destinations>
</Distribution>
<EventLink type="episodic" title="Men In Black" parentalRating="PG">
<!-- title from Listing Text Set Title
-->
<Programme>
<ProgrammeId>785432</ProgrammeId>
<!-- From ExtProgId (if it exists) or title ID
-->
</Programme>
</EventLink>
<Media>
<Source>
<Videos>
<Video source="playout" Identifier="NJ01858S" aspect_ratio="16X9" />
</Videos>
</Source>
</Media>
</CreatePromo>
</Body>
</PromoMessage>
: 여기 23,516,
그리고 출력이 보일 것입니다 방법이다.
우선 : 이전의 대시로 인해 원하는 출력이 유효한 XML이 아닙니다. 그게 의도 된거야? –
user3159253
질문을했기 때문에 잘못했는지 너무 많은 코드를 게시 (길)하는 것입니다. –