0
votes
<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 was allready in XSL Analyze-String -> Matching-Substring into multiple variables

but my question is how to use it on example to concate eg regex-group(1) with 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 I would like to have in one element

<mytrouble>
  <trouble12>AA - 03 StoLAT , Sample sam Sample</trouble12>
</mytrouble>

so the rgex group 4 - text inside ( ) from <reference1> and the whole text from opr

ps currently by transforming:

Cannot match item type with required type Error location: xsl:stylesheet / xsl:template / xsl:element / xsl:variable / @as

Details XTTE0570 : The required item type of variable ' groups ' is ' element(Q{http://xml.event/1.0}group) ' , the supplied item type is ' text() '

GREAT THANX for

michael.hor257k

almost there - just the result indicates header

<trouble12 xmlns:fn="http://www.w3.org/2005/xpath-functions">AA - 03 StoLATSample sam Sample</trouble12>
1
Please show us a small but complete and representative snippet of the XML input and then show us the result you want to create using XSLT 2.0 for that input, explaining the rules.Martin Honnen
Are you complainining about the namespace decalration xmlns:fn="http://www.w3.org/2005/xpath-functions"?michael.hor257k
yes :) but it's not complaining - it was a great help from You really but if there is a way to exclude the declaration I would be double grateful for guidanceMiG
It is caused by code that you have not shown us. I am guessing you have this declaration in your xsl:stylesheet opening tag, and you need to add exclude-result-prefixes="fn" in the same place.michael.hor257k
@michael-hor257k, of course THANX againMiG

1 Answers

0
votes

my question is how to use it on example to concate eg regex-group(1) with other element outside regex path "/fault/informations/restriction2"

To refer to another node within the xsl:analyze-string instruction, capture it in a variable first - for 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>