Skip to content

Commit

Permalink
Add link to disable xslt translation of xsd in browsers
Browse files Browse the repository at this point in the history
(also cleaned up display of array types).

By default, the xsd & wsdl include xml processing instructions
to tell a browser to use a specific xslt file to translate the
schema into html.

I was not able to figure out how to instruct the browser to
ignore this xslt, so I added a query string parameter that
would stop the server from adding the processing instruction.

This parameter is only needed in a browser.  Any schema tools
should be able to use the plan url since it will ignore the
processing instruction.
  • Loading branch information
dblain committed Mar 7, 2012
1 parent 293175a commit 1ceab85
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
26 changes: 19 additions & 7 deletions mythtv/html/xslt/class.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
</div>
</div>
<hr />
<!--
<p class="alignLeft"><xsl:value-of select="/w:definitions/w:service/w:documentation/text()" /></p>
<p class="alignRight"><a href="./wsdl?raw=1">View Xsd</a></p>
-->
<xsl:variable name="CurrentType" select="/xs:schema/xs:complexType/@name" />

<p class="alignLeft"><xsl:value-of select="//xs:documentation/text()" /></p>
<p class="alignRight"><a href="./xsd?type={$CurrentType}&amp;raw=1">View Xsd</a></p>
<br />

<div class="method" >
Expand Down Expand Up @@ -52,15 +52,27 @@

<tr>
<td></td>

<xsl:variable name="PropType" >
<xsl:choose>
<xsl:when test="starts-with(@type, 'tns:ArrayOf')">
<xsl:value-of select="concat(substring-after(@type, 'ArrayOf'), '[]')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@type" />
</xsl:otherwise>
</xsl:choose>

</xsl:variable>

<xsl:choose>
<xsl:when test="$Search and /xs:schema/xs:include[contains( @schemaLocation, $Search)]">
<td class="prop_type"><a href="{ /xs:schema/xs:include[contains( @schemaLocation, $Search)]/@schemaLocation}"><xsl:value-of select="@type"/></a></td>
<td class="prop_type"><a href="{ /xs:schema/xs:include[contains( @schemaLocation, $Search)]/@schemaLocation}"><xsl:value-of select="$PropType"/></a></td>
</xsl:when>
<xsl:otherwise>
<td class="prop_type"><xsl:value-of select="@type"/></td>
<td class="prop_type"><xsl:value-of select="$PropType"/></td>
</xsl:otherwise>
</xsl:choose>

<td class="prop_name"><xsl:value-of select="@name"/></td>
</tr>

Expand Down
8 changes: 5 additions & 3 deletions mythtv/libs/libmythupnp/xsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ bool Xsd::GetXSD( HTTPRequest *pRequest, QString sTypeName )
// Render XSD
// --------------------------------------------------------------

appendChild( createProcessingInstruction( "xml-stylesheet",
"type=\"text/xsl\" href=\"/xslt/class.xslt\"" ));

if (!pRequest->m_mapParams.contains( "raw" ))
{
appendChild( createProcessingInstruction( "xml-stylesheet",
"type=\"text/xsl\" href=\"/xslt/class.xslt\"" ));
}

if (bIsArray)
{
Expand Down

0 comments on commit 1ceab85

Please sign in to comment.