Changeset 4433


Ignore:
Timestamp:
02/05/14 09:50:26 (10 years ago)
Author:
andmor
Message:

Updated XQuery escaping technique. Fixes remaining escaping problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cats/SCHEMAcat/trunk/urn.org.basex.rest/rest/query.dpml

    r3874 r4433  
    1313                                        xmlns:rest="http://basex.org/rest">
    1414                                        <!-- transform the XQuery XML into a valid BaseX REST Query document -->
     15                                        <xsl:import href="active:sloot.xquery-wrapers.escape"/>
    1516                                        <xsl:param name="vararg"/>
    1617                                        <xsl:param name="debug"/>
     
    5051                                                                <!-- Enable BaseX 'writeback' functionality for every query -->
    5152                                                                <xsl:text>declare option db:writeback "true";</xsl:text>
    52                                                                 <xsl:apply-templates mode="copy" select="./node()"/>
     53                                                                <xsl:for-each select="./node()">
     54                                                                        <xsl:choose>
     55                                                                                <xsl:when test="self::text()">
     56                                                                                        <xsl:apply-templates select="."/>
     57                                                                                </xsl:when>
     58                                                                                <xsl:otherwise>
     59                                                                                        <xsl:apply-templates select="." mode="escape"/>
     60                                                                                </xsl:otherwise>
     61                                                                        </xsl:choose>
     62                                                                </xsl:for-each>
    5363                                                        </rest:text>
    5464                                                        <!-- pass on any additonal arguments as variables -->
     
    6777                                                        </xsl:for-each>
    6878                                                </rest:query>
    69                                         </xsl:template>
    70                                         <!-- turn an element node into an escaped XML string -->
    71                                         <xsl:template match="element()" mode="copy">
    72                                                 <xsl:text>&lt;</xsl:text>
    73                                                 <xsl:value-of select="name()"/>
    74                                                 <xsl:apply-templates select="@*" mode="#current"/>
    75                                                 <xsl:text>&gt;</xsl:text>
    76                                                 <xsl:apply-templates mode="#current"/>
    77                                                 <xsl:text>&lt;/</xsl:text>
    78                                                 <xsl:value-of select="name()"/>
    79                                                 <xsl:text>&gt;</xsl:text>
    80                                         </xsl:template>
    81                                         <!-- turn an attribute node into an escaped XML string -->
    82                                         <xsl:template match="@*" mode="copy">
    83                                                 <xsl:text> </xsl:text>
    84                                                 <xsl:value-of select="name()"/>
    85                                                 <xsl:text>="</xsl:text>
    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;')"/>
    88                                                 <xsl:text>"</xsl:text>
    89                                         </xsl:template>
    90                                         <!-- turn a text node into an escaped XML string -->
    91                                         <xsl:template match="text()" mode="copy">
    92                                                 <xsl:value-of select="normalize-space(.)"/>
    9379                                        </xsl:template>
    9480                                </xsl:stylesheet>
     
    129115                <argument name="operator">
    130116                        <literal type="xml">
    131                                 <hds>
    132                                         <Authorization>Basic {string($base64-db-auth-token)}</Authorization>
    133                                 </hds>
     117                                <query>
     118                                        <hds>
     119                                                <Authorization>Basic {string($base64-db-auth-token)}</Authorization>
     120                                        </hds>
     121                                </query>
    134122                        </literal>
    135123                </argument>
Note: See TracChangeset for help on using the changeset viewer.