xml文件的格式
<?xml version="1.0" encoding="UTF-8"?>
<DataSets>
<Metadata>
<ItemDef OID="I0001" Name="姓名" DataType="string" Length=""
SignificantDigits="" SASFieldName="" SDSVarName="" Origin=""
Comment="" DefaultValue="" Note="输入您的名字"
RangeCheckRelationship="and">
<CodeListRef Name="" />
<Question>您的姓名?</Question>
<Control qualityControl="" operationType="" />
</ItemDef>
<ItemDef OID="I0002" Name="说明信息" DataType="text" Length=""
SignificantDigits="" SASFieldName="" SDSVarName="" Origin=""
Comment="" DefaultValue="7g" Note="" RangeCheckRelationship="and">
<CodeListRef Name="" />
<Question>您的详细说明</Question>
<Control qualityControl="" operationType="" />
</ItemDef>
<ItemGroupDef OID="G0001" Name="个人描述" Repeating="yes"
IsReferenceData="0" SASDatasetName="" Domain="" Origin="" Purpose=""
Comment=""
Note="个人描述信息,包括:[r]&lt;br/&gt;[/r]1, 姓名[r]&lt;br/&gt;[/r]2, 详细描述信息">
<ItemRef ItemOID="I0001" Name="姓名" OrderNumber="1"
Mandatory="no" />
<ItemRef ItemOID="I0002" Name="说明信息" OrderNumber="2"
Mandatory="no" />
</ItemGroupDef>
<FormDef OID="F0001" Name="预诊-1" Repeating="yes"
Note="预诊信息[r]&lt;br/&gt;[/r]请详细输入">
<ItemGroupRef ItemGroupOID="G0001" Name="个人描述"
OrderNumber="1" Mandatory="no" />
</FormDef>
<StudyEventDef OID="E0001" Name="新建诊断-1" Repeating="yes"
Type="Scheduled" Category="">
<FormRef FormOID="F0001" Name="预诊-1" OrderNumber="1"
Mandatory="no" page="1" />
</StudyEventDef>
<VarDef OID="var_0" DataType="string" Lable="您的姓名?"
Remark="E0001.1//F0001.1//G0001#1.I0001" Domain="" Function="">
<ItemRef Varname="v0" ItemOID="I0001" Eventpath="E0001.1"
Formpath="F0001.1" ItemGrouppath="G0001#1" />
</VarDef>
<VarDef OID="var_1" DataType="text" Lable="您的详细说明"
Remark="E0001.1//F0001.1//G0001#1.I0002" Domain="" Function="">
<ItemRef Varname="v0" ItemOID="I0002" Eventpath="E0001.1"
Formpath="F0001.1" ItemGrouppath="G0001#1" />
</VarDef>
</Metadata>
<DataSet Subject="0010">
<Event Name="abc">
<Data Value="1" VarRefOID="var_0" />
<Data Value="2" VarRefOID="var_1" />
</Event>
</DataSet>
<DataSet Subject="0009">
<Event Name="abc">
<Data Value="1" VarRefOID="var_0" />
<Data Value="1" VarRefOID="var_1" />
</Event>
</DataSet>
<DataSet Subject="0008">
<Event Name="abc">
<Data Value="1" VarRefOID="var_0" />
<Data Value="1" VarRefOID="var_1" />
</Event>
</DataSet>
<DataSet Subject="0007">
<Event Name="abc">
<Data Value="1" VarRefOID="var_0" />
<Data Value="1" VarRefOID="var_1" />
</Event>
</DataSet>
<DataSet Subject="0006">
<Event Name="abc">
<Data Value="1" VarRefOID="var_0" />
<Data Value="2" VarRefOID="var_1" />
</Event>
</DataSet>
<DataSet Subject="0005">
<Event Name="abc">
<Data Value="1" VarRefOID="var_0" />
<Data Value="2" VarRefOID="var_1" />
</Event>
</DataSet>
<DataSet Subject="0004">
<Event Name="abc">
<Data Value="1" VarRefOID="var_0" />
<Data Value="2" VarRefOID="var_1" />
</Event>
</DataSet>
<DataSet Subject="0003">
<Event Name="abc">
<Data Value="niahoa" VarRefOID="var_0" />
<Data Value="gee " VarRefOID="var_1" />
</Event>
</DataSet>
<DataSet Subject="0002">
<Event Name="abc">
<Data Value="12" VarRefOID="var_0" />
<Data Value="3" VarRefOID="var_1" />
</Event>
</DataSet>
<DataSet Subject="0001">
<Event Name="abc">
<Data Value="qqq" VarRefOID="var_0" />
<Data Value="gg" VarRefOID="var_1" />
</Event>
</DataSet>
</DataSets>
xslt文件的格式
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:variable name="columnitems" select="//VarDef"/>
<xsl:variable name="rowitems" select="//DataSet"/>
<xsl:call-template name="listcolumns">
<xsl:with-param name="items" select="$columnitems"/>
</xsl:call-template>
<xsl:call-template name="listrows">
<xsl:with-param name="citems" select="$columnitems"/>
<xsl:with-param name="ritems" select="$rowitems"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="listcolumns">
<xsl:param name="items"/>
<xsl:text>SubjectCode,</xsl:text>
<xsl:for-each select="$items">
<xsl:choose>
<xsl:when test="position() != last() and last() >= 2">
<xsl:value-of select="@OID"/>,<xsl:text/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@OID"/><xsl:text/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text>
</xsl:text>
<xsl:text>,</xsl:text>
<xsl:for-each select="$items">
<xsl:choose>
<xsl:when test="position() != last() and last() >= 2">
<xsl:value-of select="@Label"/>,<xsl:text/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@Label"/><xsl:text/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template name="listrows">
<xsl:param name="citems"/>
<xsl:param name="ritems"/>
<xsl:for-each select="$ritems">
<xsl:text>"</xsl:text>
<xsl:value-of select="@Subject"/><xsl:text/>
<xsl:text>",</xsl:text>
<xsl:variable name="item" select="Event"/>
<xsl:call-template name="listrow">
<xsl:with-param name="dataitem" select="$item"/>
<xsl:with-param name="matchcitems" select="$citems"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="listrow">
<xsl:param name="dataitem"/>
<xsl:param name="matchcitems"/>
<xsl:for-each select="$matchcitems">
<xsl:variable name="have">
<xsl:variable name="cellname" select="@OID"/>
<xsl:call-template name="printcell">
<xsl:with-param name="cn" select="$cellname"/>
<xsl:with-param name="celldatas" select="$dataitem"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="position() != last() and last() >= 2">
<xsl:value-of select="$have"/>,<xsl:text/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$have"/><xsl:text/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template name="printcell">
<xsl:param name="cn"/>
<xsl:param name="celldatas"/>
<xsl:for-each select="$celldatas/Data">
<xsl:if test="$cn = @VarRefOID">
<xsl:text>"</xsl:text>
<xsl:value-of select="@Value"/><xsl:text/>
<xsl:text>"</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>