xslt - XSL use regex group result + other element outside regex path for one outcome element -
<xsl:variable name="groups" as="element(group)*"> <xsl:analyze-string regex="^^([0-9-]+)([a-z ]*)[ ]*([\(](.*)[\)])*$" select="/fault/informations/restriction1"> <xsl:matching-substring> <group> <x><xsl:value-of select="regex-group(1)"/></x> <y><xsl:value-of select="regex-group(4)"/></y> </group> </xsl:matching-substring> </xsl:analyze-string> </xsl:variable>
it allready in xsl analyze-string -> matching-substring multiple variables
but question how use on example concate eg regex-group(1) other element outside regex path "/fault/informations/restriction2"
so simple imput xml:
<fault > <information> <reference1>22-00 x (aa - 03 stolat)</reference1> <opr>sample sam (66-33) sample</opr> </information> </fault>
and output have in 1 element
<mytrouble> <trouble12>aa - 03 stolat , sample sam sample</trouble12> </mytrouble>
so rgex group 4 - text inside ( ) <reference1>
, whole text opr
ps transforming:
cannot match item type required type error location: xsl:stylesheet / xsl:template / xsl:element / xsl:variable / @as
details xtte0570 : required item type of variable ' groups ' ' element(q{http://xml.event/1.0}group) ' , supplied item type ' text() '
great thanx
michael.hor257k
almost there - result indicates header
<trouble12 xmlns:fn="http://www.w3.org/2005/xpath-functions">aa - 03 stolatsample sam sample</trouble12>
my question how use on example concate eg regex-group(1) other element outside regex path "/fault/informations/restriction2"
to refer node within xsl:analyze-string
instruction, capture in variable first - example:
<xsl:variable name="opr" select="fault/information/opr" /> <xsl:analyze-string regex="^^([0-9-]+)([a-z ]*)[ ]*([\(](.*)[\)])*$" select="fault/information/reference1"> <xsl:matching-substring> <trouble12> <xsl:value-of select="regex-group(4)"/> <xsl:value-of select="$opr"/> </trouble12> </xsl:matching-substring> </xsl:analyze-string>
Comments
Post a Comment