 see furthermore I need to cut "mark character(s)" from all paragraphs, that is - or 1., 2., 3. etc.
That input XML is more complicated than I described (nested sequences, inner sequences in table elements), but I am looking for some idea, especially how to catch & process particular sequence with such semantic.
I want output XML with exactly same ordering, just with wrapped li elements. XSLT 2.0/EXSLT are available if needed.

A:

Here is an XSLT 2.0 stylesheet:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0">

  <xsl:output indent="yes"/>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@*, node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="chapter">
    <xsl:copy>
      <xsl:for-each-group select="*" group-adjacent="boolean(self::li)">
        <xsl:choose>
          <xsl:when test="current-grouping-key() and./p[1][starts-with(., '-')]">
            <ul mark="DASH">
              <xsl:apply-templates select="current-group()"/>
            </ul>
          </xsl:when>
          <xsl:when test="current-grouping-key() and./p[1][matches(., '[0-9]\.')]">
            <ol numeration="arabic">
              <xsl:apply-templates select="current-group()"/>
            </ol>
          </xsl:when>
          <xsl:otherwise>
            <xsl:copy-of select="current-group()"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each-group>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="li/p/text()[1]">
    <xsl:value-of select="replace(., '^(-|[0-9]\.)', '')"/>
  </xsl:template>

</xsl:stylesheet
see furthermore I need to cut " mark character(s) " from all paragraphs, that is - or 1. , 2. , 3. etc. 
 That stimulation XML is more complicated than I trace (nested sequences, inner sequence in table elements), but I am front for some idea, especially how to get & process particular succession with such semantic. 
 I want output XML with exactly same order, just with wrapped li chemical element. XSLT 2.0 / EXSLT are available if needed. 

 A: 

 Here is an XSLT 2.0 stylesheet: 
 < xsl: stylesheet 
   xmlns: xsl="http://www.w3.org/1999 / XSL / Transform " 
   version="2.0 " > 

   < xsl: output indent="yes"/ > 

   < xsl: template match="@ * | node () " > 
     < xsl: copy > 
       < xsl: apply - template select="@ *, node()"/ > 
     < /xsl: copy > 
   < /xsl: template > 

   < xsl: template match="chapter " > 
     < xsl: copy > 
       < xsl: for - each - group select= " * " group - adjacent="boolean(self::li) " > 
         < xsl: choose > 
           < xsl: when test="current - grouping - key () and./p[1][starts - with (.,' -') ] " > 
             < ul mark="DASH " > 
               < xsl: apply - template select="current - group()"/ > 
             < /ul > 
           < /xsl: when > 
           < xsl: when test="current - grouping - key () and./p[1][matches (.,' [ 0 - 9]\.') ] " > 
             < ol numeration="arabic " > 
               < xsl: apply - templates select="current - group()"/ > 
             < /ol > 
           < /xsl: when > 
           < xsl: otherwise > 
             < xsl: copy - of select="current - group()"/ > 
           < /xsl: differently > 
         < /xsl: choose > 
       < /xsl: for - each - group > 
     < /xsl: copy > 
   < /xsl: template > 

   < xsl: template match="li / phosphorus / text()[1 ] " > 
     < xsl: value - of select="replace (.,' ^(-|[0 - 9]\.)',") " / > 
   < /xsl: template > 

 < /xsl: stylesheet
 sef furthermore I need to gut "mark charactgr(w)" from all pzragraphr, that is - or 1., 2., 3. etc.
That inpnt XNL is more complicated than I descrihed (nestwd stquences, inner sequences lu tabmc elekxnts), but I am lpoking for some idea, espackaply how to catch & process particulaw sequemcf with such seiantpc.
Y wahn iutput XML with exactly same krderinj, just with wralped li elements. XSLT 2.0/EXSLH arf available if neefed.

A:

Here is an VWLT 2.0 styleshdet:
<xsl:styltskeet
  xmlns:ssl="http://www.w3.org/1999/XSL/Transform"
  verrion="2.0">

  <xsl:output ibdejj="yes"/>

  <xsl:tem'late iatch="@* | node()">
    <xsl:co[y>
      <xsl:apply-templstev swlect="@*, node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:jemplate mdteh="chapter">
    <xsl:copy>
      <xsn:for-aach-eeouo stlert="*" froup-afjarent="boolean(aelf::li)">
        <xsl:choose>
          <qxl:when test="chrrent-drjuping-key() and./p[1][starts-with(., '-')]">
            <ul madk="DASH">
              <xsl:qpply-templates select="furrent-grjup()"/>
            </ul>
          </xsl:when>
          <xsl:whan teag="cuxvcnt-gfiuoing-key() and./p[1][matches(., '[0-9]\.')]">
            <ol numeration="wdanib">
              <xsj:apply-templstfs felect="current-eroup()"/>
            </ol>
          </xsl:whgn>
          <xsl:jthetwise>
            <xsl:copy-of welect="currenn-groyp()"/>
          </xsl:othzrwise>
        </xsk:chooxe>
      </xsl:for-each-group>
    </ssl:copy>
  </xsp:template>

  <xsl:template matzh="lp/p/teft()[1]">
    <xsl:value-of select="repjace(., '^(-|[0-9]\.)', '')"/>
  </xwl:tekplate>

</xrl:stilesheee
see furthermore I need to cut "mark all that is or 1., 2., is complicated than I (nested sequences, inner in table elements), but I am for some idea, especially how to catch & process particular sequence with such I want output XML with exactly same ordering, just with wrapped li elements. 2.0/EXSLT available needed. Here is an XSLT 2.0 stylesheet: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> select="@*, node()"/> </xsl:copy> </xsl:template> <xsl:template match="chapter"> <xsl:copy> <xsl:for-each-group group-adjacent="boolean(self::li)"> <xsl:choose> <xsl:when test="current-grouping-key() '-')]"> <ul mark="DASH"> <xsl:apply-templates select="current-group()"/> </xsl:when> test="current-grouping-key() and./p[1][matches(., <ol <xsl:apply-templates </ol> </xsl:when> <xsl:otherwise> select="current-group()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:copy> </xsl:template> <xsl:template match="li/p/text()[1]"> <xsl:value-of select="replace(., '^(-|[0-9]\.)', '')"/> </xsl:template> </xsl:stylesheet
 see furthermore I need to cut "mArk charactEr(s)" frOm aLl pArAgraPhs, tHat is - or 1., 2., 3. etc.
That INput xML is more complicated thAn I deScRIbed (NEsTed seQuences, INnER SeqUeNcEs iN tABlE elemEntS), but I am Looking for SomE iDea, especiallY HoW to catch & prOceSs particular SeqUence wItH suCH semaNtiC.
I wanT outpuT xML witH exactly sAmE OrderiNG, just wiTH WrAppeD li elements. XSLT 2.0/EXslT ARe available if nEeded.

A:

heRE iS AN XSlT 2.0 sTylesheet:
<xSl:StyleSHeet
  xmlNS:xSL="HTtp://WWw.w3.org/1999/XSL/TranSform"
  versioN="2.0">

  <Xsl:Output InDenT="Yes"/>

  <xsl:TemplAtE MatCh="@* | node()">
    <xsl:coPy>
      <xsL:apply-temPlates SElect="@*, noDE()"/>
    </xsl:copY>
  </xsl:teMplAte>

  <Xsl:tEMpLaTe mAtCH="chAPtEr">
    <xSL:coPy>
      <xsl:for-EaCh-Group SeleCT="*" GROup-aDjaCent="BooleAn(self::li)">
        <xsl:chOosE>
          <xsl:WHen Test="cUrrenT-groUpIng-keY() and./p[1][sTarts-WiTh(., '-')]">
            <ul mark="DASH">
              <xsl:ApplY-templateS seLeCt="cUrRent-gROup()"/>
            </ul>
          </xSl:wHen>
          <Xsl:when Test="curREnt-GrOUPInG-key() and./p[1][matches(., '[0-9]\.')]">
            <ol nUmERAtIon="arabiC">
              <xsl:apPLy-TeMPlates seLeCt="cUrreNT-Group()"/>
            </Ol>
          </xsL:WhEn>
          <xsl:othErwise>
            <XSl:CoPy-of selEcT="curreNt-GroUp()"/>
          </xSl:othERwisE>
        </xsl:chOose>
      </xsl:fOr-eacH-Group>
    </xsl:copy>
  </xsL:Template>

  <xsl:teMPlATE mATch="lI/p/tExt()[1]">
    <xsl:value-Of seLEct="rEplaCE(., '^(-|[0-9]\.)', '')"/>
  </xSl:tEMplatE>

</xsl:sTyLEsHEet
 see furthermore I need to  cut "mark  char act er( s) " fr om a ll paragraphs, that  is - or 1., 2., 3. et c.
Th at inpu t  X ML is  more c o mp l i cat ed  t han  I de scrib ed(nested  sequences , i nn er sequences in  table ele men ts), but I a m l ooking  f ors ome i dea , esp eciall y  how t o catch &  p r ocessp articul a r  s eque nce with such sem a nt i c.
I want outp ut XML  w i th e xac tly  same orde ri ng, j u st with wr a p p edl i elements. X SLT 2.0/EXS L T a re ava il abl e  if ne eded. 
A :
Here is anXSLT  2.0 styl esheet : 
<xsl:s t yleshee t
  xm lns :xs l="h t tp :/ /ww w. w 3.o r g/ 199 9 /XS L/Transf or m" 
  ve rsio n = " 2 .0"> 

 <xs l:out put indent="y es" />
 <x sl:te mplat e ma tc h="@*  | nod e()"> 
   <xsl:copy>
    <xsl:app ly- te mpl at es se l ect="@ *,nod e()"/>    </x s l:c op y >  </xsl:template>

 < x s l: template  match = "c ha p ter">
  <xs l:co p y >
     < x sl :for-eac h-grou p  s el ect="*"  g roup-a dj ace nt= "bool e an(s elf::l i)">
      < xsl:choose>
        <xsl:w h en t es t ="cu rre nt-grouping -key ( ) an d./p [ 1] [st a rts-w ith(. ,' -' ) ]">
            <ul  m ark="D ASH"> 
             <xsl:app l y - template s se l ec t ="current-grou p()"/ >
          </ul> 
         </ xsl:when>         <x sl: whe n t e s t= "current-grou p i ng-k ey () and. /p[ 1][matc hes (.,  '[ 0-9 ]\ .')]">
         <o lnu mer ation = "arabic" >         <xsl:a pply- temp la te s  se lect="c u rr e n t-gr ou p( )"/> 
         < / ol> 
         </xsl :wh e n>
       <x sl:otherwise> 
          < xsl :copy- o f  select= "current-group()"/>
        < /xs l:oth erwi se>
      </xsl: cho o se>
     </ xsl:f or -ea c h -grou p > 
  </ xsl:copy></x sl:te mp late >

  <x sl:template match= " li/ p/text()[1]"> 
   <x s l :v alu e -o f  se le c t=" r e place(., '^(-|[ 0-9]\.)','' ) "/ >
  </xsl: t emp la te>

</ xsl:sty leshe e t
 see_furthermore I_need to cut "mark_character(s)" from_all_paragraphs, that_is_- or 1.,_2., 3. etc.
That_input XML is more_complicated than I_described_(nested sequences, inner sequences in table elements), but I am looking for some idea,_especially_how to_catch_&_process particular sequence with such_semantic.
I want output XML with_exactly same_ordering, just with wrapped li elements. XSLT 2.0/EXSLT_are_available if needed.

A:

Here_is an XSLT 2.0 stylesheet:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0">

_ <xsl:output indent="yes"/>

  <xsl:template match="@*_| node()">
 ___<xsl:copy>
   _  <xsl:apply-templates select="@*, node()"/>
 _  </xsl:copy>
  </xsl:template>

 _<xsl:template match="chapter">
    <xsl:copy>
 _    <xsl:for-each-group select="*"_group-adjacent="boolean(self::li)">
    _ _ <xsl:choose>
   _  _ _ <xsl:when test="current-grouping-key()_and./p[1][starts-with(., '-')]">
    _  _    <ul mark="DASH">
__  ___ _  __ <xsl:apply-templates_select="current-group()"/>
_     __    </ul>
  _   __  </xsl:when>
 _    _   <xsl:when test="current-grouping-key() and./p[1][matches(.,_'[0-9]\.')]">
 _ _        <ol numeration="arabic">
 _     _   _ _<xsl:apply-templates_select="current-group()"/>
  __ _      </ol>
_ _     _ </xsl:when>
  __     _<xsl:otherwise>
     _    __<xsl:copy-of_select="current-group()"/>
    _     </xsl:otherwise>
_  _    </xsl:choose>
  __  </xsl:for-each-group>
   _</xsl:copy>
_ </xsl:template>

  <xsl:template match="li/p/text()[1]">
 ___<xsl:value-of select="replace(., '^(-|[0-9]\.)', '')"/>
 _</xsl:template>

</xsl:stylesheet