edwinuestc的个人博客分享 http://blog.sciencenet.cn/u/edwinuestc

博文

第一版样式表

已有 2185 次阅读 2012-5-1 01:26 |个人分类:程序调试|系统分类:科研笔记

svrl report result.xml所对应的样式表
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:s="http://purl.oclc.org/dsdl/schematron" xmlns:ax21="http://validation.hitsp.nist.gov/xsd">
<xsl:output method="html" encoding="GB2312" media-type="text/xhtml "/>
<xsl:template match="/">
<html>
<body>
<table border="0">
<tr>
<td id="header" style="width: 602">
<img src="images/HL7china.png" alt="HL7 China logo" style="width: 602 height :   140 hspace :   0 vspace :   0 border :   0"/>
</td>
</tr>
<tr>
<td colspan="2">
<h1 style="text-align: center">HL7 China Clinical Document Architecture (CDA) 测试平台</h1>
</td>
</tr>
<tr bgcolor="#6495ED">
<th colspan="4">CDA文档验证概况</th>
</tr>
<tr>
<td colspan="4">
<table width="60%" border="1" align="center">
<tr>
<td align="center">文件名称</td>
<td align="center">结果</td>
<td align="center">统计</td>
</tr>
<tr>
<td width="35%">
<xsl:value-of select="fileset/file/@name"/>
</td>
<td width="15%">
<xsl:choose>
<xsl:when test="count(//svrl:failed-assert)='0'">
<font color="green">有效</font>>
    </xsl:when>
<xsl:otherwise>
<font color="red">无效</font>
</xsl:otherwise>
</xsl:choose>
</td>
<td>

错误:<xsl:value-of select="count(//svrl:failed-assert)"/>
</br>

warning: <xsl:value-of select="count(a[key('lookup', generate-id())]/@id[contains(.,'warning')]) " /> 
</br>
<a href="#SampleCCDDocument.xml">(查看详细报告)</a>
</br>
</td>
</tr>
</table>
<p>
<b>
<a href="这里要给我们的链接">验证其他文件</a></b>
</p>
<h3><A NAME="SampleCCDDocument.xml">CDA文档的验证报告</A></h3>


<p><b>验证: MOH Schematron Schema (错误)</b></p>



<blockquote>



<p>
<xsl:choose>
<xsl:when test="count(//svrl:failed-assert)
+count(//svrl:failed-assert/@svrl:text[contains(.,'Error')])
+count(//svrl:failed-assert/@svrl:text[contains(.,'错误')])='0'">
<font color="green">No issues found</font>
</xsl:when>
<xsl:otherwise>
<font color="red">
<xsl:apply-templates />
</font>
</xsl:otherwise>
</xsl:choose>
</p>
</blockquote>

<p><b><a href="这里要给我们的链接">验证其他文件</a>.</b></p>
</td>
</tr>
<tr>
</tr>

</table>
</body>
</html>
</xsl:template>
<xsl:key name="lookup" match="svrl:failed-assert" use="generate-id(preceding-sibling::svrl:active-pattern[1])" />
   <xsl:template match="/fileset/file/svrl:schematron-output">
      <xsl:apply-templates select="svrl:active-pattern[key('lookup', generate-id())]" />
   </xsl:template>

   <xsl:template match="svrl:active-pattern">
      <xsl:value-of select="concat(@name, ':&#13;', '&#13;')" />
      <xsl:apply-templates select="key('lookup', generate-id())" />
   </xsl:template>

   <xsl:template match="svrl:failed-assert">
      <xsl:apply-templates select="@*" />
      <xsl:value-of select="'&#13;'" />
   </xsl:template>

<xsl:template name="svrl:failed-assert" match="svrl:failed-assert">
<table width="800">
  <tr>
 <td colspan="2"><font color="red"><xsl:value-of select="svrl:text" />
</font></td>
  </tr>
  <tr>
 <td width="50">Location:</td>
 <td width="750">
 <i>
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text">
<xsl:call-template name="string-replace-all">
  <xsl:with-param name="text" select="@location"/>
  <xsl:with-param name="replace" select="&quot;*[local-name()='&quot;"/>
  <xsl:with-param name="by" select="''"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="replace" select="&quot;']&quot;"/>
<xsl:with-param name="by" select="''"/>
 </xsl:call-template> 
 </i></td>
  </tr>
  <tr>
 <td width="50">Test:;</td>
 <td width="750"><i><xsl:value-of select="@test" /></i></td>
  </tr>
</table>
</xsl:template>
 <xsl:template name="string-replace-all">
    <xsl:param name="text" />
    <xsl:param name="replace" />
    <xsl:param name="by" />
    <xsl:choose>
      <xsl:when test="contains($text, $replace)">
        <xsl:value-of select="substring-before($text,$replace)" />
        <xsl:value-of select="$by" />
        <xsl:call-template name="string-replace-all">
          <xsl:with-param name="text"
          select="substring-after($text,$replace)" />
          <xsl:with-param name="replace" select="$replace" />
          <xsl:with-param name="by" select="$by" />
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>


https://wap.sciencenet.cn/blog-615874-565395.html

上一篇:显示特定的标签值
下一篇:mayo的自然语言处理工具
收藏 IP: 121.49.127.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-14 08:14

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部