Предполагается, что мы говорим о разборе фиксированной ширины ввода:
Это легко сделать в XSLT 2.0 с помощью регулярных выражений и xsl:analyze-string
:
XML
<input>LP12018122908001884LP22018122908001884LP72018122908001884</input>
XSLT 2.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<output>
<xsl:analyze-string select="input" regex="(.{{2}})(.)(.{{8}})(.{{8}})">
<xsl:matching-substring>
<entry>
<type><xsl:value-of select="regex-group(1)"/></type>
<week><xsl:value-of select="regex-group(2)"/></week>
<date><xsl:value-of select="regex-group(3)"/></date>
<location><xsl:value-of select="regex-group(4)"/></location>
</entry>
</xsl:matching-substring>
</xsl:analyze-string>
</output>
</xsl:template>
</xsl:stylesheet>
Результат
<?xml version="1.0" encoding="UTF-8"?>
<output>
<entry>
<type>LP</type>
<week>1</week>
<date>20181229</date>
<location>08001884</location>
</entry>
<entry>
<type>LP</type>
<week>2</week>
<date>20181229</date>
<location>08001884</location>
</entry>
<entry>
<type>LP</type>
<week>7</week>
<date>20181229</date>
<location>08001884</location>
</entry>
</output>
Демо : http://xsltransform.hikmatu.com/3NzcBsL
Сделать то же самое в XSLT 1.0 немного сложнее:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<root>
<xsl:call-template name="create-entries">
<xsl:with-param name="string" select="input"/>
</xsl:call-template>
</root>
</xsl:template>
<xsl:template name="create-entries">
<xsl:param name="string"/>
<xsl:variable name="entry" select="substring($string, 1, 19)" />
<entry>
<type><xsl:value-of select="substring($entry, 1, 2)"/></type>
<week><xsl:value-of select="substring($entry, 3, 1)"/></week>
<date><xsl:value-of select="substring($entry, 4, 8)"/></date>
<location><xsl:value-of select="substring($entry, 13, 8)"/></location>
</entry>
<xsl:if test="string-length($string) > 19">
<!-- recursive call -->
<xsl:call-template name="create-entries">
<xsl:with-param name="string" select="substring($string, 20)" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Демо: http://xsltransform.hikmatu.com/3NzcBsL/1