Re: Happy Birthday Norm

Cool work Gerrit,

and of course congratulations to Norm

----- Oorspronkelijk bericht -----
Van: "gerrit imsieke" <gerrit.imsieke@le-tex.de>
Aan: "XProc Dev" <xproc-dev@w3.org>
Verzonden: Vrijdag 16 juni 2017 09:49:45
Onderwerp: Happy Birthday Norm

Dear Norm,

All the best wishes, and please accept this recursive, lyrics-generating 
XProc step as a gist er gift.

–Gerrit

https://gist.github.com/gimsieke/8f869d2681a31fd249051e927bfdcf68

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
   xmlns:ndw50="urn:ndw:birthday:50"
   xmlns:c="http://www.w3.org/ns/xproc-step"
   xmlns:cx="http://xmlcalabash.com/ns/extensions"
   version="1.0"
   exclude-inline-prefixes="c cx ndw50"
   type="ndw50:serenade" name="serenade">

   <p:output port="serenade-lines" sequence="true">
     <p:pipe port="lines" step="finished-yet"/>
   </p:output>
   <p:output port="result" primary="true"/>
   <p:serialization port="result" indent="true" 
omit-xml-declaration="false"/>

   <p:option name="times" select="'50'"/>

   <p:input port="source" sequence="true" primary="true">
     <p:inline><line xmlns="http://docbook.org/ns/docbook">Happy 
birthday to you.</line></p:inline>
   </p:input>

   <p:split-sequence initial-only="true" test="position() = 1" 
name="first-line"/>

   <p:sink/>

   <p:count name="count">
     <p:input port="source">
       <p:pipe port="source" step="serenade"/>
     </p:input>
   </p:count>

   <p:sink/>

   <p:choose name="finished-yet">
     <p:xpath-context>
       <p:pipe port="result" step="count"/>
     </p:xpath-context>
     <p:when test="number(/*) lt number($times)">
       <p:output port="lines" sequence="true">
         <p:pipe port="serenade-lines" step="recurse"/>
       </p:output>
       <p:output port="serenade" primary="true">
         <p:pipe port="result" step="recurse"/>
       </p:output>
       <ndw50:serenade name="recurse">
         <p:input port="source">
           <p:pipe port="matched" step="first-line"/>
           <p:pipe port="source" step="serenade"/>
         </p:input>
         <p:with-option name="times" select="$times"/>
       </ndw50:serenade>
       <p:sink/>
     </p:when>
     <p:otherwise>
       <p:output port="lines" sequence="true"/>
       <p:output port="serenade" primary="true"/>
       <p:wrap-sequence wrapper="poetry" 
wrapper-namespace="http://docbook.org/ns/docbook" name="w1">
         <p:input port="source">
           <p:pipe port="source" step="serenade"/>
         </p:input>
       </p:wrap-sequence>
       <p:insert match="/*" position="last-child" name="i1">
         <p:input port="insertion">
           <p:inline><line xmlns="http://docbook.org/ns/docbook">Happy 
birthday dear Norman!</line></p:inline>
         </p:input>
       </p:insert>
       <p:insert match="/*" position="last-child" name="i2">
         <p:input port="insertion">
           <p:pipe port="matched" step="first-line"/>
         </p:input>
       </p:insert>
     </p:otherwise>
   </p:choose>

</p:declare-step>

Received on Friday, 16 June 2017 08:27:04 UTC