У меня есть требование, когда мне нужно разбить следующий текст на три отдельных блока XML. A должен быть одним блоком, B другим блоком и C другим блоком.
<line cnt="16"><![CDATA[ A B C]]></line>
<line cnt="17"/>
<line cnt="18"><![CDATA[TOTAL 2583000 0 4800000]]></line>
<line cnt="19"/>
<line cnt="20"><![CDATA[06:00 - 07:00 ValueA ValueB ValueC]]></line>
<line cnt="21"><![CDATA[07:00 - 08:00 ValueA ValueB ValueC]]></line>
<line cnt="22"><![CDATA[08:00 - 09:00 107625 0 200000]]></line>
<line cnt="23"><![CDATA[09:00 - 10:00 107625 0 200000]]></line>
<line cnt="24"><![CDATA[10:00 - 11:00 107625 0 200000]]></line>
<line cnt="25"><![CDATA[11:00 - 12:00 107625 0 200000]]></line>
<line cnt="26"><![CDATA[12:00 - 13:00 107625 0 200000]]></line>
<line cnt="27"><![CDATA[13:00 - 14:00 107625 0 200000]]></line>
<line cnt="28"><![CDATA[14:00 - 15:00 107625 0 200000]]></line>
<line cnt="29"><![CDATA[15:00 - 16:00 107625 0 200000]]></line>
<line cnt="30"><![CDATA[16:00 - 17:00 107625 0 200000]]></line>
<line cnt="31"><![CDATA[17:00 - 18:00 107625 0 200000]]></line>
<line cnt="32"><![CDATA[18:00 - 19:00 107625 0 200000]]></line>
<line cnt="33"><![CDATA[19:00 - 20:00 107625 0 200000]]></line>
<line cnt="34"><![CDATA[20:00 - 21:00 107625 0 200000]]></line>
<line cnt="35"><![CDATA[21:00 - 22:00 107625 0 200000]]></line>
<line cnt="36"><![CDATA[22:00 - 23:00 107625 0 200000]]></line>
<line cnt="37"><![CDATA[23:00 - 00:00 107625 0 200000]]></line>
<line cnt="38"><![CDATA[00:00 - 01:00 107625 0 200000]]></line>
<line cnt="39"><![CDATA[01:00 - 02:00 107625 0 200000]]></line>
<line cnt="40"><![CDATA[02:00 - 03:00 107625 0 200000]]></line>
<line cnt="41"><![CDATA[03:00 - 04:00 107625 0 200000]]></line>
<line cnt="42"><![CDATA[04:00 - 05:00 107625 0 200000]]></line>
<line cnt="43"><![CDATA[05:00 - 06:00 107625 0 200000]]></line>
Пример исходящего блокадолжно быть
<Block>
<Contract ContractID="xxx"/>
<Location CodeAgency="xxx" LocID="A" LocQualifier="xxx"/>
<DataSeries ValueType="xxx" ValueQualifier="xxx" ValueUnit="xxx" ValueInterval="xxx">
<Data Value="ValueA" TimeFrom="2019-10-11T04:00:00Z" TimeTo="2019-10-11T05:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T05:00:00Z" TimeTo="2019-10-11T06:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T06:00:00Z" TimeTo="2019-10-11T07:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T07:00:00Z" TimeTo="2019-10-11T08:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T08:00:00Z" TimeTo="2019-10-11T09:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T09:00:00Z" TimeTo="2019-10-11T10:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T10:00:00Z" TimeTo="2019-10-11T11:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T11:00:00Z" TimeTo="2019-10-11T12:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T12:00:00Z" TimeTo="2019-10-11T13:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T13:00:00Z" TimeTo="2019-10-11T14:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T14:00:00Z" TimeTo="2019-10-11T15:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T15:00:00Z" TimeTo="2019-10-11T16:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T16:00:00Z" TimeTo="2019-10-11T17:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T17:00:00Z" TimeTo="2019-10-11T18:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T18:00:00Z" TimeTo="2019-10-11T19:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T19:00:00Z" TimeTo="2019-10-11T20:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T20:00:00Z" TimeTo="2019-10-11T21:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T21:00:00Z" TimeTo="2019-10-11T22:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T22:00:00Z" TimeTo="2019-10-11T23:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-11T23:00:00Z" TimeTo="2019-10-12T00:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-12T00:00:00Z" TimeTo="2019-10-12T01:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-12T01:00:00Z" TimeTo="2019-10-12T02:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-12T02:00:00Z" TimeTo="2019-10-12T03:00:00Z"/>
<Data Value="ValueA" TimeFrom="2019-10-12T03:00:00Z" TimeTo="2019-10-12T04:00:00Z"/>
</DataSeries>
</Block>
<Block>
<Contract ContractID="xxx"/>
<Location CodeAgency="xxx" LocID="B" LocQualifier="xxx"/>
<DataSeries ValueType="xxx" ValueQualifier="xxx" ValueUnit="xxx" ValueInterval="xxx">
<Data Value="ValueB" TimeFrom="2019-10-11T04:00:00Z" TimeTo="2019-10-11T05:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T05:00:00Z" TimeTo="2019-10-11T06:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T06:00:00Z" TimeTo="2019-10-11T07:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T07:00:00Z" TimeTo="2019-10-11T08:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T08:00:00Z" TimeTo="2019-10-11T09:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T09:00:00Z" TimeTo="2019-10-11T10:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T10:00:00Z" TimeTo="2019-10-11T11:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T11:00:00Z" TimeTo="2019-10-11T12:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T12:00:00Z" TimeTo="2019-10-11T13:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T13:00:00Z" TimeTo="2019-10-11T14:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T14:00:00Z" TimeTo="2019-10-11T15:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T15:00:00Z" TimeTo="2019-10-11T16:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T16:00:00Z" TimeTo="2019-10-11T17:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T17:00:00Z" TimeTo="2019-10-11T18:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T18:00:00Z" TimeTo="2019-10-11T19:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T19:00:00Z" TimeTo="2019-10-11T20:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T20:00:00Z" TimeTo="2019-10-11T21:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T21:00:00Z" TimeTo="2019-10-11T22:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T22:00:00Z" TimeTo="2019-10-11T23:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-11T23:00:00Z" TimeTo="2019-10-12T00:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-12T00:00:00Z" TimeTo="2019-10-12T01:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-12T01:00:00Z" TimeTo="2019-10-12T02:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-12T02:00:00Z" TimeTo="2019-10-12T03:00:00Z"/>
<Data Value="ValueB" TimeFrom="2019-10-12T03:00:00Z" TimeTo="2019-10-12T04:00:00Z"/>
</DataSeries>
</Block>
<Block>
<Contract ContractID="xxx"/>
<Location CodeAgency="xxx" LocID="C" LocQualifier="xxx"/>
<DataSeries ValueType="xxx" ValueQualifier="xxx" ValueUnit="xxx" ValueInterval="xxx">
<Data Value="ValueC" TimeFrom="2019-10-11T06:00:00Z" TimeTo="2019-10-11T07:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T07:00:00Z" TimeTo="2019-10-11T08:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T08:00:00Z" TimeTo="2019-10-11T09:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T09:00:00Z" TimeTo="2019-10-11T10:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T10:00:00Z" TimeTo="2019-10-11T11:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T11:00:00Z" TimeTo="2019-10-11T12:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T12:00:00Z" TimeTo="2019-10-11T13:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T13:00:00Z" TimeTo="2019-10-11T14:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T14:00:00Z" TimeTo="2019-10-11T15:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T15:00:00Z" TimeTo="2019-10-11T16:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T16:00:00Z" TimeTo="2019-10-11T17:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T17:00:00Z" TimeTo="2019-10-11T18:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T18:00:00Z" TimeTo="2019-10-11T19:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T19:00:00Z" TimeTo="2019-10-11T20:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T20:00:00Z" TimeTo="2019-10-11T21:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T21:00:00Z" TimeTo="2019-10-11T22:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T22:00:00Z" TimeTo="2019-10-11T23:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T23:00:00Z" TimeTo="2019-10-11T00:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T00:00:00Z" TimeTo="2019-10-11T01:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T01:00:00Z" TimeTo="2019-10-11T02:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T02:00:00Z" TimeTo="2019-10-11T03:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T03:00:00Z" TimeTo="2019-10-11T04:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T04:00:00Z" TimeTo="2019-10-11T05:00:00Z"/>
<Data Value="ValueC" TimeFrom="2019-10-11T05:00:00Z" TimeTo="2019-10-11T06:00:00Z"/>
</Block>
Я пытаюсь адаптировать следующую кодировку XSLT, этот фрагмент может быть показан по запросу. Основная сложность для меня - создать код, который будет разделять идентификаторы местоположения и соответствующие им почасовые значения на блоки.
<xsl:template match="/">
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:variable name="from">
<xsl:value-of select="normalize-space(substring-before(substring-after(//line[contains(translate(text(), $uppercase, $smallcase),'period:')]/text(),':'),'-'))"/>
</xsl:variable>
<xsl:variable name="to">
<xsl:value-of select="normalize-space(substring-after(substring-after(//line[contains(translate(text(), $uppercase, $smallcase),'period:')]/text(),':'),'-'))"/>
</xsl:variable>
<xsl:variable name="auction">
<xsl:choose>
<xsl:when test="//line[contains(text(),'successful participation in the following auction')]">true</xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<OwnerId>
<xsl:variable name="lineId">
<xsl:value-of select="//line[contains(translate(text(),$uppercase, $smallcase), 'the bid was placed by:') or contains(translate(text(),$uppercase, $smallcase), 'the capacity was booked by:')]/@cnt + 1"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains(//line[@cnt=$lineId]/text(),'Shell Energy')">
<xsl:value-of select ="2"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select ="1"/>
</xsl:otherwise>
</xsl:choose>
</OwnerId>
<DealId>
<xsl:value-of select="normalize-space(substring-after(translate(//line[contains(translate(text(), $uppercase, $smallcase),'deal id:')]/text(),'/',' '),':'))"/>
</DealId>
<xsl:variable name="NB_Booking">
<xsl:value-of select="normalize-space(substring-after(//line[contains(translate(text(), $uppercase, $smallcase),'tso:')]/text(),':'))"/>
</xsl:variable>
<NetpointId>
<xsl:value-of select="concat(substring-before($NB_Booking,' '),'#',normalize-space(substring-after(//line[contains(translate(text(), $uppercase, $smallcase),'id of network point:')]/text(),':')))"/>
</NetpointId>
<Direction>
<xsl:value-of select="translate(normalize-space(substring-after(//line[contains(translate(text(), $uppercase, $smallcase),'direction:')]/text(),':')),'e','E')"/>
</Direction>
<DayAhead>
<!-- wenn milliseconds fuer addhour(from) = milliseconds fuer to dann true-->
<xsl:choose>
<xsl:when test="ut:getTimeStamp(ut:addDay($from,1,1,1),4) = ut:getTimeStamp($to,1)">
<xsl:value-of select="'true'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'false'"/>
</xsl:otherwise>
</xsl:choose>
</DayAhead>