Advertisement
dcramer

Adding xinclude to working pipeline

Dec 31st, 2011
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 4.14 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <p:declare-step version="1.0"
  4.  xmlns:p="http://www.w3.org/ns/xproc"
  5.  name="main">
  6.  
  7.   <p:input port="source" /> <!--sequence="false" primary="true"-->
  8.   <p:input port="schema" sequence="true" >
  9.     <p:document  href="http://docs-beta.rackspace.com/oxygen/13.1/mac/author/frameworks/rackbook/5.0/rng/rackbook.rng"/> <!--http://docs-beta.rackspace.com/oxygen/13.1/mac/author/frameworks/rackbook/5.0/-->
  10.   </p:input>
  11.  
  12.   <p:output port="result" primary="true">  
  13.     <p:pipe step="programlisting-keep-together-xslt" port="result"/>  
  14.   </p:output>  
  15.   <p:output port="report" sequence="true">  
  16.     <p:pipe step="tryvalidation" port="report"/>  
  17.   </p:output>
  18.   <p:serialization port="report" indent="true"/>
  19.  
  20.   <!--
  21.    Problem, the p:xinclude causes
  22.    "Description: ERR : Unbound primary output: [output result on included]"
  23.   -->  
  24.   <p:xinclude name="included">
  25.     <p:input port="source">                      
  26.       <p:pipe step="main"
  27.        port="source"/>
  28.     </p:input>
  29.   </p:xinclude>
  30.  
  31.   <p:try name="tryvalidation">
  32.     <p:group>
  33.       <p:output port="result">
  34.         <p:pipe step="xmlvalidate" port="result"/>  
  35.       </p:output>
  36.       <p:output port="report" sequence="true">
  37.         <p:empty/>
  38.       </p:output>      
  39.      
  40.       <p:validate-with-relax-ng name="xmlvalidate"  assert-valid="true">
  41.         <p:input port="source">
  42.           <p:pipe step="main" port="source"/>
  43.         </p:input>
  44.         <p:input port="schema">
  45.           <p:pipe step="main" port="schema"/>  
  46.         </p:input>  
  47.       </p:validate-with-relax-ng>  
  48.      
  49.     </p:group>  
  50.     <p:catch name="catch">  
  51.       <p:output port="result">  
  52.         <p:pipe step="main" port="source"/>  
  53.       </p:output>  
  54.       <p:output port="report">  
  55.         <p:pipe step="id" port="result"/>
  56.       </p:output>  
  57.       <p:xslt name="id">
  58.         <p:input port="source">  
  59.           <p:pipe step="catch" port="error"/>  
  60.         </p:input>  
  61.         <p:input port="stylesheet">
  62.           <p:inline>
  63.             <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  64.              
  65.               <xsl:param name="failonerror">yes</xsl:param>
  66.              
  67.               <xsl:template match="node()|@*">
  68.                 <xsl:message terminate="{$failonerror}">
  69.                   <xsl:copy-of select="."/>
  70.                 </xsl:message>    
  71.                 <xsl:copy>
  72.                   <xsl:apply-templates select="node() | @*"/>
  73.                 </xsl:copy>
  74.               </xsl:template>
  75.              
  76.             </xsl:stylesheet>
  77.           </p:inline>
  78.         </p:input>
  79.         <p:input port="parameters" sequence="true">
  80.           <p:empty/>
  81.         </p:input>
  82.       </p:xslt>
  83.     </p:catch>  
  84.   </p:try>
  85.  
  86.   <p:xslt name="programlisting-keep-together-xslt">
  87.     <p:input port="source">
  88.       <p:pipe step="main" port="source"/>
  89.     </p:input>
  90.     <p:input port="stylesheet">
  91.       <p:inline>
  92.         <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  93.          xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:db="http://docbook.org/ns/docbook"
  94.          exclude-result-prefixes="xs" version="2.0">
  95.          
  96.           <xsl:template match="node() | @*">
  97.             <xsl:copy>
  98.               <xsl:apply-templates select="node() | @*"/>
  99.             </xsl:copy>
  100.           </xsl:template>
  101.          
  102.           <xsl:param name="max">8</xsl:param>
  103.          
  104.           <xsl:template match="db:programlisting">
  105.             <xsl:copy>
  106.               <xsl:apply-templates select="@*"/>
  107.               <xsl:if test="count(tokenize(.,'&#xA;')) &lt; $max">
  108.                 <xsl:processing-instruction name="dbfo">keep-together="always"</xsl:processing-instruction>
  109.               </xsl:if>
  110.               <xsl:apply-templates select="node()"/>
  111.             </xsl:copy>
  112.           </xsl:template>
  113.          
  114.         </xsl:stylesheet>
  115.       </p:inline>
  116.       <!--<p:document href="cloud/code-listing-keep-together.xsl"/>-->
  117.     </p:input>
  118.     <p:input port="parameters" sequence="true">
  119.       <p:empty/>
  120.     </p:input>
  121.   </p:xslt>
  122.  
  123. </p:declare-step>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement