Skip to content

Commit

Permalink
Make relation between input templates, output templates, and profile …
Browse files Browse the repository at this point in the history
…explicit on the info/ page #62
  • Loading branch information
proycon committed Mar 22, 2018
1 parent ca8faa1 commit 307c580
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
4 changes: 4 additions & 0 deletions clam/common/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,8 @@ def xml(self, indent = ""):
xml +=" filename=\""+clam.common.util.xmlescape(self.filename)+"\""
if self.extension:
xml +=" extension=\""+clam.common.util.xmlescape(self.extension)+"\""
if self.parent:
xml +=" parent=\""+clam.common.util.xmlescape(self.parent)+"\""
if self.unique:
xml +=" unique=\"yes\""
else:
Expand Down Expand Up @@ -1821,6 +1823,8 @@ def fromxml(node):
kwargs['extension'] = node.attrib['extension']
if 'unique' in node.attrib:
kwargs['unique'] = node.attrib['unique'].lower() == 'yes' or node.attrib['unique'].lower() == 'true' or node.attrib['unique'].lower() == '1'
if 'parent' in node.attrib:
kwargs['parent'] = node.attrib['parent']

#find formatclass
formatcls = None
Expand Down
38 changes: 23 additions & 15 deletions clam/static/info.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@
</li>
<li><strong>Upload one or more files</strong> - Issue a <tt>HTTP POST</tt> on <tt><xsl:value-of select="@baseurl"/>/<em>{yourprojectname}</em>/input/<em>{filename}</em></tt>. The POST request takes the following parameters:
<ul>
<li><tt>inputtemplate</tt> - The input template for this upload, determines the type of file that is expected. The <em><xsl:value-of select="@name"/></em> webservice defines the following Input Templates:
<ul>
<xsl:for-each select="//InputTemplate">
<li><tt>inputtemplate=<xsl:value-of select="@id" /></tt> - <xsl:value-of select="@label" /> (<xsl:value-of select="@format" />). If you use this input template you can specify the following extra parameters:
<ul>
<xsl:apply-templates />
</ul>
</li>
</xsl:for-each>
</ul>
<li><tt>inputtemplate</tt> - The input template for this upload, determines the type of file that is expected. The <em><xsl:value-of select="@name"/></em> webservice defines the following Input Templates (grouped per profile):
<ol>
<xsl:for-each select="//profile">
<li>Profile #<xsl:value-of select="position()" /><ul>
<xsl:for-each select=".//InputTemplate">
<li><tt>inputtemplate=<span style="color: blue"><xsl:value-of select="@id" /></span></tt> - <xsl:value-of select="@label" /> (<xsl:value-of select="@format" />). If you use this input template you can specify the following extra parameters:
<ul>
<xsl:apply-templates />
</ul>
</li>
</xsl:for-each>
</ul></li>
</xsl:for-each>
</ol>
</li>
<li><tt>file</tt> - HTTP file data.</li>
<li><tt>contents</tt> - full string contents of the file (can be used as an alternative to of file)</li>
Expand Down Expand Up @@ -101,11 +105,15 @@
Curl example (getting project state only, no intepretation): <tt>curl <xsl:call-template name="curlauth" /> -v -X GET <xsl:value-of select="@baseurl"/>/<em>$yourprojectname</em></tt>
</li>
<li><strong>Retrieve the desired output file(s)</strong> - Issue a <tt>HTTP GET</tt> on <tt><xsl:value-of select="@baseurl"/>/<em>{yourprojectname}</em>/output/<em>{outputfilename}</em></tt>. A list of available output files can be obtained by querying the project's state (HTTP GET on <tt><xsl:value-of select="@baseurl"/>/<em>{yourprojectname}</em>/</tt>) and iterating over <tt>/CLAM/output/file/name</tt> (XPath). A <tt>template</tt> attribute will be available on these nodes indicating what output template was responsible for generating this file. The following output templates are defined for this webservice:
<ul>
<xsl:for-each select="//OutputTemplate">
<li><tt><xsl:value-of select="@id" /></tt> - <xsl:value-of select="@label" /> (<xsl:value-of select="@format" />). </li>
</xsl:for-each>
</ul>
<ol>
<xsl:for-each select="//profile">
<li>Profile #<xsl:value-of select="position()" /><ul>
<xsl:for-each select=".//OutputTemplate">
<li><tt><xsl:value-of select="@id" /></tt> - <xsl:value-of select="@label" /> (<xsl:value-of select="@format" />). <xsl:if test="@parent">[from input template <tt><xsl:value-of select="@parent" /></tt>]</xsl:if></li>
</xsl:for-each>
</ul></li>
</xsl:for-each>
</ol>
<br /><em>Responses:</em>
<ul>
<li>Will respond with <tt>HTTP 200 OK</tt> if successful, and returns the content of the file (along with the correct mime-type for it)</li>
Expand Down
5 changes: 5 additions & 0 deletions docs/clam.rng
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ RelaxNG schema for CLAM XML
<attribute name="unique">
<a:documentation>Boolean value set to "true" or "false", determining whether this output template is unique and produces only one file, or whether multiple files can be produces using this input template</a:documentation>
</attribute>
</optional>
<optional>
<attribute name="parent">
<a:documentation>The ID of the inputtemplate that acts as the parent for this output template</a:documentation>
</attribute>
</optional>
<zeroOrMore>
<choice>
Expand Down

0 comments on commit 307c580

Please sign in to comment.