Changeset 3092 for cats/shared


Ignore:
Timestamp:
07/01/13 13:12:42 (11 years ago)
Author:
mwindhouwer
Message:
  • added active:sloot.dpml a DPML preprocessor, currently supports:
    • wrap debug statements in

<sloot-debug>...</sloot-debug>

and en/disable them using a debug="true|false" attribute on the root element

  • profile a section of DPML by wrapping it in

<sloot-profile name="...">...</sloot-profile>

and en/disable it using a profile="true|false" attribute on the root element

  • made debugging of active:sloot.xpath2 and active:sloot.xquery optional
Location:
cats/shared/urn.org.isocat.sloot/trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • cats/shared/urn.org.isocat.sloot/trunk/module.xml

    r3077 r3092  
    6767               </request>
    6868            </endpoint>
     69            <endpoint>
     70               <grammar>
     71                  <active>
     72                     <identifier>active:sloot.dpml</identifier>
     73                     <argument name="operator"/>
     74                     <varargs/>
     75                  </active>
     76               </grammar>
     77               <verbs>SOURCE,SINK,EXISTS,DELETE,NEW</verbs>
     78               <request>
     79                  <identifier>active:dpml</identifier>
     80                  <argument name="operator">res:/tools/pp-dpml.dpml</argument>
     81                  <argument name="sloot-operator">arg:operator</argument>
     82                  <varargs/>
     83               </request>
     84            </endpoint>
    6985         </config>
    7086         <space>
     
    7490            <fileset>
    7591               <regex>res:/debug/.*</regex>
     92               <mutable/>
    7693            </fileset>
    7794            <import>
  • cats/shared/urn.org.isocat.sloot/trunk/tools/xpath2.dpml

    r3004 r3092  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<sequence>
    3         <!-- use xquery to turn any operand into an XML, so we can conveniently evaluate a XPath expression -->
     3        <literal assignment="debug" type="boolean">false</literal>
     4        <!-- use xquery to turn any operand into an XML, so we can conveniently evaluate a XPath expression -->
    45        <request assignment="o">
    56                <identifier>active:xquery</identifier>
    67                <argument name="operator">
    7                         <literal type="string">
     8                        <literal type="string"
     9                                >
    810                                declare variable $o external;
    9                                 &lt;o>{$o}&lt;/o>
     11                                if ($o instance of node()) then ($o) else (&lt;o>{$o}&lt;/o>)
    1012                        </literal>
    1113                </argument>
    1214                <argument name="o">arg:operand</argument>
    1315        </request>
    14         <log>
    15                 <level>INFO</level>
    16                 <message>
    17                         <literal type="string">[%1]</literal>
    18                 </message>
    19                 <param>this:o</param>
    20         </log>
     16        <if>
     17                <cond>
     18                        <request>
     19                                <identifier>this:debug</identifier>
     20                        </request>
     21                </cond>
     22                <then>
     23                        <log>
     24                                <level>INFO</level>
     25                                <message>
     26                                        <literal type="string">sloot.xpath: [%1] ? [%2]</literal>
     27                                </message>
     28                                <param>this:o</param>
     29                                <param>arg:xpath</param>
     30                        </log>
     31                </then>
     32        </if>
    2133        <request assignment="response">
    2234                <identifier>active:xpath2</identifier>
     
    2436                <argument name="operator">arg:xpath</argument>
    2537        </request>
    26         <log>
    27                 <level>INFO</level>
    28                 <message>
    29                         <literal type="string">[%1] ? [%2] = [%3]</literal>
    30                 </message>
    31                 <param>arg:operand</param>
    32                 <param>arg:xpath</param>
    33                 <param>this:response</param>
    34         </log>
     38        <if>
     39                <cond>
     40                        <request>
     41                                <identifier>this:debug</identifier>
     42                        </request>
     43                </cond>
     44                <then>
     45                        <log>
     46                                <level>INFO</level>
     47                                <message>
     48                                        <literal type="string">sloot.xpath: [%1] ? [%2] = [%3]</literal>
     49                                </message>
     50                                <param>arg:operand</param>
     51                                <param>arg:xpath</param>
     52                                <param>this:response</param>
     53                        </log>
     54                </then>
     55        </if>
    3556</sequence>
  • cats/shared/urn.org.isocat.sloot/trunk/tools/xquery.dpml

    r3077 r3092  
    22<sequence>
    33        <!-- convenience wrapper around active:xquery, which allows to have the XQuery as an XML literal so its wellformedness is easily checked -->
    4         <request>
    5                 <verb>SINK</verb>
    6                 <identifier>res:/debug/sloot.xquery.query.xml</identifier>
    7                 <argument name="primary">arg:query</argument>
    8         </request>
     4        <literal assignment="debug" type="boolean">false</literal>
     5        <if>
     6                <cond>
     7                        <request>
     8                                <identifier>this:debug</identifier>
     9                        </request>
     10                </cond>
     11                <then>
     12                        <request>
     13                                <verb>SINK</verb>
     14                                <identifier>res:/debug/sloot.xquery.query.xml</identifier>
     15                                <argument name="primary">arg:query</argument>
     16                        </request>
     17                </then>
     18        </if>
    919        <request assignment="query">
    1020                <identifier>active:xslt2</identifier>
     
    2030                                                <xsl:variable name="query">
    2131                                                        <!-- turn the namespaces in scope of the root element into 'declare namespace' statements -->
    22                                                         <xsl:for-each select="in-scope-prefixes($root)[not(.=('xml','xs','xsi','fn','local'))]">
     32                                                        <xsl:for-each
     33                                                                select="in-scope-prefixes($root)[not(.=('xml','xs','xsi','fn','local'))]">
    2334                                                                <xsl:variable name="prefix" select="current()"/>
    2435                                                                <xsl:choose>
    2536                                                                        <xsl:when test="$prefix=''">
    2637                                                                                <xsl:text>declare default namespace "</xsl:text>
    27                                                                                 <xsl:value-of select="namespace-uri-for-prefix($prefix,$root)"/>
     38                                                                                <xsl:value-of
     39                                                                                        select="namespace-uri-for-prefix($prefix,$root)"/>
    2840                                                                                <xsl:text>";</xsl:text>
    2941                                                                                <xsl:value-of select="$NL"/>
     
    3345                                                                                <xsl:value-of select="$prefix"/>
    3446                                                                                <xsl:text> = "</xsl:text>
    35                                                                                 <xsl:value-of select="namespace-uri-for-prefix($prefix,$root)"/>
     47                                                                                <xsl:value-of
     48                                                                                        select="namespace-uri-for-prefix($prefix,$root)"/>
    3649                                                                                <xsl:text>";</xsl:text>
    3750                                                                                <xsl:value-of select="$NL"/>
     
    4053                                                        </xsl:for-each>
    4154                                                        <!-- turn the arguments into 'declare variable' statements -->
    42                                                         <xsl:for-each select="$vararg/arguments/*[not(name()=('operand','operator'))]">
     55                                                        <xsl:for-each
     56                                                                select="$vararg/arguments/*[not(name()=('operand','operator'))]">
    4357                                                                <xsl:variable name="var" select="name()"/>
    44                                                                 <xsl:message>DBG: variable name[<xsl:value-of select="$var"/>]</xsl:message>
     58                                                                <xsl:message>DBG: variable name[<xsl:value-of select="$var"
     59                                                                        />]</xsl:message>
    4560                                                                <xsl:text>declare variable $</xsl:text>
    4661                                                                <xsl:value-of select="$var"/>
     
    6984                                                <xsl:value-of select="name()"/>
    7085                                                <xsl:text>="</xsl:text>
    71                                                 <xsl:value-of select="replace(replace(replace(replace(replace(.,'&amp;','&amp;amp;'),''&apos;','&amp;apos;'),'&lt;','&amp;lt;'),'&gt;','&amp;gt;'),'&quot;','&amp;quot;')"/>
     86                                                <xsl:value-of
     87                                                        select="replace(replace(replace(replace(replace(.,'&amp;','&amp;amp;'),''&apos;','&amp;apos;'),'&lt;','&amp;lt;'),'&gt;','&amp;gt;'),'&quot;','&amp;quot;')"/>
    7288                                                <xsl:text>"</xsl:text>
    7389                                        </xsl:template>
    7490                                        <!-- turn a text node into an escaped XML string -->
    7591                                        <xsl:template match="text()">
    76                                                 <xsl:value-of select="replace(replace(replace(replace(replace(.,'&amp;','&amp;amp;'),''&apos;','&amp;apos;'),'&lt;','&amp;lt;'),'&gt;','&amp;gt;'),'&quot;','&amp;quot;')"/>
     92                                                <xsl:value-of
     93                                                        select="replace(replace(replace(replace(replace(.,'&amp;','&amp;amp;'),''&apos;','&amp;apos;'),'&lt;','&amp;lt;'),'&gt;','&amp;gt;'),'&quot;','&amp;quot;')"
     94                                                />
    7795                                        </xsl:template>
    7896                                </xsl:stylesheet>
     
    94112                </argument>
    95113        </request>
    96         <request>
    97                 <verb>SINK</verb>
    98                 <identifier>res:/debug/sloot.xquery.query.xq</identifier>
    99                 <argument name="primary">this:query</argument>
    100         </request>
     114        <if>
     115                <cond>
     116                        <request>
     117                                <identifier>this:debug</identifier>
     118                        </request>
     119                </cond>
     120                <then>
     121                        <request>
     122                                <verb>SINK</verb>
     123                                <identifier>res:/debug/sloot.xquery.query.xq</identifier>
     124                                <argument name="primary">this:query</argument>
     125                        </request>
     126                </then>
     127        </if>
    101128        <request assignment="response">
    102129                <identifier>active:xquery</identifier>
     
    104131                <varargs/>
    105132        </request>
    106         <request>
    107                 <verb>SINK</verb>
    108                 <identifier>res:/debug/sloot.xquery.result.xml</identifier>
    109                 <argument name="primary">this:response</argument>
    110         </request>
     133        <if>
     134                <cond>
     135                        <request>
     136                                <identifier>this:debug</identifier>
     137                        </request>
     138                </cond>
     139                <then>
     140                        <request>
     141                                <verb>SINK</verb>
     142                                <identifier>res:/debug/sloot.xquery.result.xml</identifier>
     143                                <argument name="primary">this:response</argument>
     144                        </request>
     145                </then>
     146        </if>
    111147</sequence>
Note: See TracChangeset for help on using the changeset viewer.