📄 metadata.xsl.svn-base
字号:
<xsl:template name="getContent"> <xsl:param name="schema"/> <xsl:param name="edit" select="false()"/> <xsl:choose> <xsl:when test="$edit=true()"> <xsl:apply-templates mode="elementEP" select="@*"> <xsl:with-param name="schema" select="$schema"/> <xsl:with-param name="edit" select="true()"/> </xsl:apply-templates> <xsl:apply-templates mode="elementEP" select="*[namespace-uri(.)!=$geonetUri]|geonet:child"> <xsl:with-param name="schema" select="$schema"/> <xsl:with-param name="edit" select="true()"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <xsl:apply-templates mode="elementEP" select="@*"> <xsl:with-param name="schema" select="$schema"/> <xsl:with-param name="edit" select="false()"/> </xsl:apply-templates> <xsl:apply-templates mode="elementEP" select="*"> <xsl:with-param name="schema" select="$schema"/> <xsl:with-param name="edit" select="false()"/> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- returns the help url --> <xsl:template name="getHelpLink"> <xsl:param name="name"/> <xsl:param name="schema"/> <xsl:variable name="help" select="string(/root/gui/*[name(.)=$schema]/*[name(.)=$name]/@help)"/> <xsl:if test="$help"> <xsl:value-of select="concat(/root/gui/locService,'/help.metadata?schema=',$schema,'&name=',$name,'#',$name)"/> </xsl:if> </xsl:template> <xsl:template name="getButtons"> <xsl:param name="addLink"/> <xsl:param name="removeLink"/> <xsl:param name="upLink"/> <xsl:param name="downLink"/> <!-- add button --> <xsl:if test="normalize-space($addLink)"> <xsl:text> </xsl:text> <a href="{$addLink}"><img src="{/root/gui/url}/images/plus.gif" alt="{/root/gui/strings/add}"/></a> </xsl:if> <!-- remove button --> <xsl:if test="normalize-space($removeLink)"> <xsl:text> </xsl:text> <a href="{$removeLink}"><img src="{/root/gui/url}/images/del.gif" alt="{/root/gui/strings/del}"/></a> </xsl:if> <!-- up button --> <xsl:if test="normalize-space($upLink)"> <xsl:text> </xsl:text> <a href="{$upLink}"><img src="{/root/gui/url}/images/up.gif" alt="{/root/gui/strings/up}"/></a> </xsl:if> <!-- down button --> <xsl:if test="normalize-space($downLink)"> <xsl:text> </xsl:text> <a href="{$downLink}"><img src="{/root/gui/url}/images/down.gif" alt="{/root/gui/strings/down}"/></a> </xsl:if> </xsl:template> <!-- translates CR-LF sequences into HTML newlines <p/> --> <xsl:template name="preformatted"> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text,' ')"> <xsl:value-of select="substring-before($text,' ')"/> <br/> <xsl:call-template name="preformatted"> <xsl:with-param name="text" select="substring-after($text,' ')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- XML formatting --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- draws an element as xml document --> <xsl:template mode="xmlDocument" match="*"> <xsl:param name="edit" select="false()"/> <xsl:choose> <xsl:when test="$edit=true()"> <tr><td> <textarea class="md" name="data" rows="30" cols="100"> <xsl:text><?xml version="1.0" encoding="UTF-8"?></xsl:text> <xsl:text> </xsl:text> <xsl:apply-templates mode="editXMLElement" select="."/> </textarea> </td></tr> </xsl:when> <xsl:otherwise> <tr><td> <b><xsl:text><?xml version="1.0" encoding="UTF-8"?></xsl:text></b><br/> <xsl:apply-templates mode="showXMLElement" select="."/> </td></tr> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- draws an editable element in xml --> <xsl:template mode="editXMLElement" match="*"> <xsl:param name="indent"/> <xsl:choose> <!-- has children --> <xsl:when test="*[not(starts-with(name(),'geonet:'))]"> <xsl:call-template name="editXMLStartTag"> <xsl:with-param name="indent" select="$indent"/> </xsl:call-template> <xsl:text> </xsl:text> <xsl:for-each select="*"> <xsl:apply-templates select="." mode="editXMLElement"> <xsl:with-param name="indent" select="concat($indent, '	')"/> </xsl:apply-templates> </xsl:for-each> <xsl:call-template name="editEndTag"> <xsl:with-param name="indent" select="$indent"/> </xsl:call-template> <xsl:text> </xsl:text> </xsl:when> <!-- no children but text --> <xsl:when test="text()"> <xsl:call-template name="editXMLStartTag"> <xsl:with-param name="indent" select="$indent"/> </xsl:call-template> <!-- xml entities should be doubly escaped --> <xsl:apply-templates mode="escapeXMLEntities" select="text()"/> <!-- <xsl:value-of select="text()"/> --> <xsl:call-template name="editEndTag"/> <xsl:text> </xsl:text> </xsl:when> <!-- empty element --> <xsl:otherwise> <xsl:call-template name="editXMLStartEndTag"> <xsl:with-param name="indent" select="$indent"/> </xsl:call-template> <xsl:text> </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- draws the start tag of an editable element --> <xsl:template name="editXMLStartTag"> <xsl:param name="indent"/> <xsl:value-of select="$indent"/> <xsl:text><</xsl:text> <xsl:value-of select="name(.)"/> <xsl:call-template name="editXMLNamespaces"/> <xsl:call-template name="editXMLAttributes"/> <xsl:text>></xsl:text> </xsl:template> <!-- draws the end tag of an editable element --> <xsl:template name="editEndTag"> <xsl:param name="indent"/> <xsl:value-of select="$indent"/> <xsl:text></</xsl:text> <xsl:value-of select="name(.)"/> <xsl:text>></xsl:text> </xsl:template> <!-- draws the empty tag of an editable element --> <xsl:template name="editXMLStartEndTag"> <xsl:param name="indent"/> <xsl:value-of select="$indent"/> <xsl:text><</xsl:text> <xsl:value-of select="name(.)"/> <xsl:call-template name="editXMLNamespaces"/> <xsl:call-template name="editXMLAttributes"/> <xsl:text>/></xsl:text> </xsl:template> <!-- draws attribute of an editable element --> <xsl:template name="editXMLAttributes"> <xsl:for-each select="@*"> <xsl:text> </xsl:text> <xsl:value-of select="name(.)"/> <xsl:text>=</xsl:text> <xsl:text>"</xsl:text> <xsl:value-of select="string()"/> <xsl:text>"</xsl:text> </xsl:for-each> </xsl:template> <!-- draws namespaces of an editable element --> <xsl:template name="editXMLNamespaces"> <xsl:variable name="parent" select=".."/> <xsl:for-each select="namespace::*"> <xsl:if test="not(.=$parent/namespace::*) and name()!='geonet'"> <xsl:text> xmlns</xsl:text> <xsl:if test="name()"> <xsl:text>:</xsl:text> <xsl:value-of select="name()"/> </xsl:if> <xsl:text>=</xsl:text> <xsl:text>"</xsl:text> <xsl:value-of select="string()"/> <xsl:text>"</xsl:text> </xsl:if> </xsl:for-each> </xsl:template> <!-- draws an element in xml --> <xsl:template mode="showXMLElement" match="*"> <xsl:choose> <!-- has children --> <xsl:when test="*"> <xsl:call-template name="showXMLStartTag"/> <dl> <xsl:for-each select="*"> <dd> <xsl:apply-templates select="." mode="showXMLElement"/> </dd> </xsl:for-each> </dl> <xsl:call-template name="showEndTag"/> </xsl:when> <!-- no children but text --> <xsl:when test="text()"> <xsl:call-template name="showXMLStartTag"/> <xsl:value-of select="text()"/> <xsl:call-template name="showEndTag"/> </xsl:when> <!-- empty element --> <xsl:otherwise> <xsl:call-template name="showXMLStartEndTag"/> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- draws the start tag of an element --> <xsl:template name="showXMLStartTag"> <font color="4444ff"> <xsl:text><</xsl:text> <b> <xsl:value-of select="name(.)"/> </b> <xsl:call-template name="showXMLNamespaces"/> <xsl:call-template name="showXMLAttributes"/> <xsl:text>></xsl:text> </font> </xsl:template> <!-- draws the end tag of an element --> <xsl:template name="showEndTag"> <font color="4444ff"> <xsl:text></</xsl:text> <b> <xsl:value-of select="name(.)"/> </b> <xsl:text>></xsl:text> </font> </xsl:template> <!-- draws the empty tag of an element --> <xsl:template name="showXMLStartEndTag"> <font color="4444ff"> <xsl:text><</xsl:text> <b> <xsl:value-of select="name(.)"/> </b> <xsl:call-template name="showXMLNamespaces"/> <xsl:call-template name="showXMLAttributes"/> <xsl:text>/></xsl:text> </font> </xsl:template> <!-- draws attributes of an element --> <xsl:template name="showXMLAttributes"> <xsl:for-each select="@*"> <xsl:text> </xsl:text> <xsl:value-of select="name(.)"/> <xsl:text>=</xsl:text> <font color="ff4444"> <xsl:text>"</xsl:text> <xsl:value-of select="string()"/> <xsl:text>"</xsl:text> </font> </xsl:for-each> </xsl:template> <!-- draws namespaces of an element --> <xsl:template name="showXMLNamespaces"> <xsl:variable name="parent" select=".."/> <xsl:for-each select="namespace::*"> <xsl:if test="not(.=$parent/namespace::*) and name()!='geonet'"> <xsl:text> xmlns</xsl:text> <xsl:if test="name()"> <xsl:text>:</xsl:text> <xsl:value-of select="name()"/> </xsl:if> <xsl:text>=</xsl:text> <font color="888844"> <xsl:text>"</xsl:text> <xsl:value-of select="string()"/> <xsl:text>"</xsl:text> </font> </xsl:if> </xsl:for-each> </xsl:template> <!-- prevent drawing of geonet:* elements --> <xsl:template mode="showXMLElement" match="geonet:*"/> <xsl:template mode="editXMLElement" match="geonet:*"/> </xsl:stylesheet>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -