Avoid spurious "no body required" text in guides generated from wadl

When testing the @mediaType of representations, only look at the
end of the string to see if it ends with xml or json when deciding
if we have an xml or json representation.

Fix typo in spelling of pseduo-attribute on PI for suppressing
the "no response body" text:
<?rax-wadl skipNoResponseText="true"?>
(Was skipNoResponeText)

Change-Id: I885f60361728dfb9ed4e364e680dbf90d964612f
Closes-Bug: #1268723
This commit is contained in:
David Cramer
2014-06-30 10:01:13 -05:00
parent 30cc4b0fd5
commit b1986f74d9

View File

@@ -237,7 +237,7 @@
<xsl:if test="ancestor-or-self::*/processing-instruction('rax-wadl')">
<xsl:call-template name="pi-attribute">
<xsl:with-param name="pis" select="ancestor-or-self::*/processing-instruction('rax-wadl')"/>
<xsl:with-param name="attribute" select="'skipNoResponeText'"/>
<xsl:with-param name="attribute" select="'skipNoResponseText'"/>
</xsl:call-template>
</xsl:if>
</xsl:with-param>
@@ -406,7 +406,7 @@
<!-- 2. If we find a request with a media type of application/xml that doesn't have an element attr or -->
<!-- 3. If we find a request with a media type of application/json that doesn't contains a { -->
<!-- The contortions are needed because the writers sometimes put in code samples with just headers. -->
<xsl:if test="not($skipNoRequestText) and (not(wadl:request) or wadl:request[wadl:representation[@mediaType = 'application/xml' and not(@element)]] or wadl:request[wadl:representation[@mediaType = 'application/json' and not((for $code in .//xsdxt:code return if(contains($code,'{') or contains($code,'[')) then 1 else 0) = 1)]])">
<xsl:if test="not($skipNoRequestText) and (not(wadl:request) or wadl:request[wadl:representation[ends-with(@mediaType, 'xml') and not(@element)]] or wadl:request[wadl:representation[@mediaType = 'application/json' and not((for $code in .//xsdxt:code return if(contains($code,'{') or contains($code,'[')) then 1 else 0) = 1)]])">
<xsl:copy-of select="$wadl.norequest.msg"/>
</xsl:if>
</section>
@@ -434,7 +434,7 @@
<!-- 2. If we find a 2xx response with a media type of application/xml that doesn't have an element attr or -->
<!-- 3. If we find a 2xx response with a media type of application/json that doesn't contains a { -->
<!-- The contortions are needed because the writers sometimes put in code samples with just headers. -->
<xsl:if test="not($skipNoResponseText) and (wadl:response[starts-with(normalize-space(@status),'2') and ./wadl:representation[@mediaType = 'application/xml' and not(@element)]] or wadl:response[starts-with(normalize-space(@status),'2') and wadl:representation[@mediaType = 'application/json' and not((for $code in .//xsdxt:code return if(contains($code,'{') or contains($code,'[')) then 1 else 0) = 1)]])">
<xsl:if test="not($skipNoResponseText) and (wadl:response[starts-with(normalize-space(@status),'2') and ./wadl:representation[ends-with(@mediaType, 'application/xml') and not(@element)]] or wadl:response[starts-with(normalize-space(@status),'2') and wadl:representation[@mediaType = 'application/json' and not((for $code in .//xsdxt:code return if(contains($code,'{') or contains($code,'[')) then 1 else 0) = 1)]])">
<xsl:copy-of select="$wadl.noresponse.msg"/>
</xsl:if>
</section>