📄 metadata.xsl.svn-base
字号:
<!-- shows editable fields for a simple element --> <xsl:template name="editSimpleElement"> <xsl:param name="schema"/> <xsl:param name="title"/> <xsl:param name="text"/> <xsl:param name="helpLink"/> <!-- if it's the last brother of it's type and there is a new brother make addLink --> <xsl:variable name="name" select="name(.)"/> <xsl:variable name="nextBrother" select="following-sibling::*[1]"/> <xsl:variable name="newBrother" select="$nextBrother[name(.)='geonet:child' and @name=$name]"/> <xsl:variable name="addLink"> <xsl:if test="$newBrother and not($newBrother/geonet:choose)"> <xsl:value-of select="concat('javascript:doNewElementAction(',$apos,/root/gui/locService,'/metadata.elem.add',$apos,',',../geonet:element/@ref,',',$apos,$name,$apos,');')"/> </xsl:if> </xsl:variable> <xsl:variable name="removeLink"> <xsl:if test="geonet:element/@del='true'"> <xsl:value-of select="concat('javascript:doElementAction(',$apos,/root/gui/locService,'/metadata.elem.delete',$apos,',',geonet:element/@ref,');')"/> </xsl:if> </xsl:variable> <xsl:variable name="upLink"> <xsl:if test="geonet:element/@up='true'"> <xsl:value-of select="concat('javascript:doElementAction(',$apos,/root/gui/locService,'/metadata.elem.up',$apos,',',geonet:element/@ref,');')"/> </xsl:if> </xsl:variable> <xsl:variable name="downLink"> <xsl:if test="geonet:element/@down='true'"> <xsl:value-of select="concat('javascript:doElementAction(',$apos,/root/gui/locService,'/metadata.elem.down',$apos,',',geonet:element/@ref,');')"/> </xsl:if> </xsl:variable> <xsl:call-template name="simpleElementGui"> <xsl:with-param name="title" select="$title"/> <xsl:with-param name="text" select="$text"/> <xsl:with-param name="addLink" select="$addLink"/> <xsl:with-param name="removeLink" select="$removeLink"/> <xsl:with-param name="upLink" select="$upLink"/> <xsl:with-param name="downLink" select="$downLink"/> <xsl:with-param name="helpLink" select="$helpLink"/> </xsl:call-template> </xsl:template> <!-- shows editable fields for an attribute --> <!-- FIXME: not schema-configurable --> <xsl:template name="editAttribute"> <xsl:param name="schema"/> <xsl:param name="title"/> <xsl:param name="text"/> <xsl:param name="helpLink"/> <xsl:variable name="name" select="name(.)"/> <xsl:variable name="value" select="string(.)"/> <xsl:call-template name="simpleElementGui"> <xsl:with-param name="title" select="$title"/> <xsl:with-param name="text" select="$text"/> <xsl:with-param name="helpLink" select="$helpLink"/> </xsl:call-template> </xsl:template> <!-- shows editable fields for a complex element --> <xsl:template name="editComplexElement"> <xsl:param name="schema"/> <xsl:param name="title"/> <xsl:param name="content"/> <xsl:param name="helpLink"/> <!-- if it's the last brother of it's type and there is a new brother make addLink --> <xsl:variable name="name" select="name(.)"/> <xsl:variable name="nextBrother" select="following-sibling::*[1]"/> <xsl:variable name="newBrother" select="$nextBrother[name(.)='geonet:child' and @name=$name]"/> <xsl:variable name="addLink"> <xsl:if test="$newBrother and not($newBrother/geonet:choose)"> <xsl:value-of select="concat('javascript:doNewElementAction(',$apos,/root/gui/locService,'/metadata.elem.add',$apos,',',../geonet:element/@ref,',',$apos,$name,$apos,');')"/> </xsl:if> </xsl:variable> <xsl:variable name="removeLink"> <xsl:if test="geonet:element/@del='true'"> <xsl:value-of select="concat('javascript:doElementAction(',$apos,/root/gui/locService,'/metadata.elem.delete',$apos,',',geonet:element/@ref,');')"/> </xsl:if> </xsl:variable> <xsl:variable name="upLink"> <xsl:if test="geonet:element/@up='true'"> <xsl:value-of select="concat('javascript:doElementAction(',$apos,/root/gui/locService,'/metadata.elem.up',$apos,',',geonet:element/@ref,');')"/> </xsl:if> </xsl:variable> <xsl:variable name="downLink"> <xsl:if test="geonet:element/@down='true'"> <xsl:value-of select="concat('javascript:doElementAction(',$apos,/root/gui/locService,'/metadata.elem.down',$apos,',',geonet:element/@ref,');')"/> </xsl:if> </xsl:variable> <xsl:call-template name="complexElementGui"> <xsl:with-param name="title" select="$title"/> <xsl:with-param name="text" select="text()"/> <xsl:with-param name="content" select="$content"/> <xsl:with-param name="addLink" select="$addLink"/> <xsl:with-param name="removeLink" select="$removeLink"/> <xsl:with-param name="upLink" select="$upLink"/> <xsl:with-param name="downLink" select="$downLink"/> <xsl:with-param name="helpLink" select="$helpLink"/> <xsl:with-param name="schema" select="$schema"/> </xsl:call-template> </xsl:template> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- gui templates --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- gui to show a simple element --> <xsl:template name="simpleElementGui"> <xsl:param name="title"/> <xsl:param name="text"/> <xsl:param name="helpLink"/> <xsl:param name="addLink"/> <xsl:param name="removeLink"/> <xsl:param name="upLink"/> <xsl:param name="downLink"/> <xsl:param name="schema"/> <!-- used as do*ElementAction url anchor to go back to the same position after editing operations --> <xsl:param name="anchor"> <xsl:choose> <!-- current node is an element --> <xsl:when test="geonet:element/@ref">_<xsl:value-of select="geonet:element/@ref"/></xsl:when> <!-- current node is an attribute or a new child: create anchor to parent --> <xsl:when test="../geonet:element/@ref">_<xsl:value-of select="../geonet:element/@ref"/></xsl:when> </xsl:choose> </xsl:param> <tr> <th class="md" width="20%" valign="top"> <a name="{$anchor}"/> <xsl:choose> <xsl:when test="$helpLink!=''"> <a href="javascript:popNew('{$helpLink}')"><xsl:value-of select="$title"/></a> </xsl:when> <xsl:otherwise> <xsl:value-of select="$title"/> </xsl:otherwise> </xsl:choose> <xsl:text> </xsl:text> <xsl:call-template name="getButtons"> <xsl:with-param name="addLink" select="$addLink"/> <xsl:with-param name="removeLink" select="$removeLink"/> <xsl:with-param name="upLink" select="$upLink"/> <xsl:with-param name="downLink" select="$downLink"/> </xsl:call-template> </th> <td class="padded" valign="top"><xsl:copy-of select="$text"/></td> </tr> </xsl:template> <!-- gui to show a complex element --> <xsl:template name="complexElementGui"> <xsl:param name="title"/> <xsl:param name="text"/> <xsl:param name="content"/> <xsl:param name="helpLink"/> <xsl:param name="addLink"/> <xsl:param name="removeLink"/> <xsl:param name="upLink"/> <xsl:param name="downLink"/> <xsl:param name="schema"/> <!-- used as do*ElementAction url anchor to go back to the same position after editing operations --> <xsl:param name="anchor"> <xsl:choose> <!-- current node is an element --> <xsl:when test="geonet:element/@ref">_<xsl:value-of select="geonet:element/@ref"/></xsl:when> <!-- current node is a new child: create anchor to parent --> <xsl:when test="../geonet:element/@ref">_<xsl:value-of select="../geonet:element/@ref"/></xsl:when> </xsl:choose> </xsl:param> <tr> <td class="padded-content" width="100%" colspan="2"> <table width="100%"> <tr> <td class="content" valign="bottom" colspan="3"> <table width="100%"><tr> <td class="green-content" width="20%"> <xsl:text>::</xsl:text> <a name="{$anchor}"/> <xsl:choose> <xsl:when test="$helpLink!=''"> <a class="green-content" href="javascript:popNew('{$helpLink}')"><xsl:value-of select="$title"/></a> </xsl:when> <xsl:otherwise> <xsl:value-of select="$title"/> </xsl:otherwise> </xsl:choose> <xsl:call-template name="getButtons"> <xsl:with-param name="addLink" select="$addLink"/> <xsl:with-param name="removeLink" select="$removeLink"/> <xsl:with-param name="upLink" select="$upLink"/> <xsl:with-param name="downLink" select="$downLink"/> </xsl:call-template> </td> <td class="content" width="100%" valign="bottom"> <table width="100%"><tr><td class="dots"/></tr></table> </td> </tr></table> </td> </tr> <tr> <td class="dots"> </td> <td class="padded-content" align="center"> <table width="100%"> <xsl:copy-of select="$content"/> </table> </td> <td class="dots"> </td> </tr> <tr><td class="dots" colspan="3"/></tr> </table> </td> </tr> </xsl:template> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- utility templates --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- returns the title of an element --> <xsl:template name="getTitle"> <xsl:param name="name"/> <xsl:param name="schema"/> <xsl:variable name="title" select="string(/root/gui/*[name(.)=$schema]/*[name(.)=$name])"/> <xsl:choose> <xsl:when test="$title"> <xsl:value-of select="$title"/> </xsl:when> <xsl:otherwise> [<xsl:value-of select="$name"/>] </xsl:otherwise> </xsl:choose> </xsl:template> <!-- returns the text of an element --> <xsl:template name="getElementText"> <xsl:param name="schema"/> <xsl:param name="edit" select="false()"/> <xsl:param name="rows" select="1"/> <xsl:param name="cols" select="50"/> <xsl:variable name="name" select="name(.)"/> <xsl:variable name="value" select="string(.)"/> <xsl:variable name="label" select="string(/root/gui/*[name(.)=$schema]/codelist[string(@name)=$name]/*[@value=$value])"/> <xsl:choose> <!-- list of values --> <xsl:when test="geonet:element/geonet:text"> <select class="md" name="_{geonet:element/@ref}" size="1"> <option name=""/> <xsl:for-each select="geonet:element/geonet:text"> <option> <xsl:if test="@value=$value"> <xsl:attribute name="selected"/> </xsl:if> <xsl:variable name="choiceValue" select="string(@value)"/> <xsl:attribute name="value"><xsl:value-of select="$choiceValue"/></xsl:attribute> <xsl:variable name="label" select="string(/root/gui/*[name(.)=$schema]/codelist[string(@name)=$name]/*[@value=$choiceValue])"/> <xsl:choose> <xsl:when test="$label"><xsl:value-of select="$label"/></xsl:when> <xsl:otherwise><xsl:value-of select="$choiceValue"/></xsl:otherwise> </xsl:choose> </option> </xsl:for-each> </select> </xsl:when> <xsl:when test="$edit=true() and $rows=1"> <input class="md" type="text" name="_{geonet:element/@ref}" value="{text()}" size="{$cols}" /> </xsl:when> <xsl:when test="$edit=true()"> <textarea class="md" name="_{geonet:element/@ref}" rows="{$rows}" cols="{$cols}"> <xsl:value-of select="text()"/> </textarea> </xsl:when> <xsl:when test="$edit=false() and $rows!=1"> <xsl:call-template name="preformatted"> <xsl:with-param name="text" select="$value"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="$label"><xsl:value-of select="$label"/></xsl:when> <xsl:otherwise><xsl:value-of select="$value"/></xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- returns the text of an attribute --> <xsl:template name="getAttributeText"> <xsl:param name="schema"/> <xsl:param name="edit" select="false()"/> <xsl:param name="rows" select="1"/> <xsl:param name="cols" select="50"/> <xsl:variable name="name" select="name(.)"/> <xsl:variable name="value" select="string(.)"/> <xsl:variable name="parent" select="name(..)"/> <xsl:choose> <!-- list of values --> <xsl:when test="../geonet:attribute[string(@name)=$name]/geonet:text"> <select class="md" name="_{../geonet:element/@ref}_{name(.)}" size="1"> <option name=""/> <xsl:for-each select="../geonet:attribute/geonet:text"> <option> <xsl:if test="@value=$value"> <xsl:attribute name="selected"/> </xsl:if> <xsl:variable name="choiceValue" select="string(@value)"/> <xsl:attribute name="value"><xsl:value-of select="$choiceValue"/></xsl:attribute> <xsl:variable name="label" select="string(/root/gui/*[name(.)=$schema]/codelist[string(@name)=$parent]/*[name()=$name and @value=$choiceValue])"/> <xsl:choose> <xsl:when test="$label"><xsl:value-of select="$label"/></xsl:when> <xsl:otherwise><xsl:value-of select="$choiceValue"/></xsl:otherwise> </xsl:choose> </option> </xsl:for-each> </select> </xsl:when> <xsl:when test="$edit=true() and $rows=1"> <input class="md" type="text" name="_{../geonet:element/@ref}_{name(.)}" value="{string()}" size="{$cols}" /> </xsl:when> <xsl:when test="$edit=true()"> <textarea class="md" name="_{../geonet:element/@ref}_{name(.)}" rows="{$rows}" cols="{$cols}"> <xsl:value-of select="string()"/> </textarea> </xsl:when> <xsl:otherwise> <xsl:variable name="label" select="string(/root/gui/*[name(.)=$schema]/codelist[string(@name)=$parent]/*[name()=$name and @value=$value])"/> <xsl:choose> <xsl:when test="$label"><xsl:value-of select="$label"/></xsl:when> <xsl:otherwise><xsl:value-of select="$value"/></xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- returns the content of a complex element -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -