以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  新手求助  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=288)


--  作者:菜鸟lika
--  发布时间:12/12/2003 8:35:00 AM

--  新手求助
我是新手,最近才接触xml语言,近来老师要我们做个题目,为同学录,要求
1。xml文档 5到10个同学的信息  10个以上的元素
2。用到dtd/schema几xsl/css
哪个老大能给我点帮助,谢谢

--  作者:haiwei_wang
--  发布时间:12/15/2003 12:15:00 AM

--  
schema文件

<?xml version="1.0" encoding="gb2312"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by hyf270 (ibm) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:complexType name="stud_type">
  <xs:sequence>
   <xs:element ref="name"/>
   <xs:element ref="password"/>
   <xs:element ref="gender"/>
   <xs:element ref="birthday"/>
   <xs:element ref="nation"/>
   <xs:element ref="hometown"/>
   <xs:element ref="homeAddress"/>
   <xs:element ref="IDCard"/>
   <xs:element ref="entranceDate"/>
   <xs:element ref="schLen"/>
   <xs:element ref="grade"/>
   <xs:element ref="specialty"/>
   <xs:element ref="depart"/>
   <xs:element ref="phone"/>
   <xs:element ref="photo"/>
  </xs:sequence>
  <xs:attribute name="studNo" type="xs:ID" use="required"/>
 </xs:complexType>
 <xs:element name="stud" type="stud_type"/>
 <xs:element name="name">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="false"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="password">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="true"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="gender">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="gender_type">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="false"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="birthday">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:date">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="false"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="nation">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="false"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="hometown">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="true"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="homeAddress">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="true"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="IDCard">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="true"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="entranceDate">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:date">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="true"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="schLen">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="true"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="grade">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="true"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="specialty">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="true"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="depart">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="true"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="phone" default="无">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:string">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="true"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:element name="photo" default="无">
  <xs:complexType>
   <xs:simpleContent>
    <xs:extension base="xs:anyURI">
     <xs:attribute name="isRevamp" type="xs:boolean" use="optional" default="false"/>
    </xs:extension>
   </xs:simpleContent>
  </xs:complexType>
 </xs:element>
 <xs:simpleType name="gender_type">
  <xs:restriction base="xs:short">
   <xs:enumeration value="0"/>
   <xs:enumeration value="1"/>
  </xs:restriction>
 </xs:simpleType>
</xs:schema>


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
xml文件

<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSPY v2004 rel. 3 U (http://www.xmlspy.com)-->
<?xml-stylesheet type="text/xsl" href="xml\stud.xslt"?>
<stud xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="G:\My\mySoft\studproject\xml\stud.xsd" studNo="ID000001">
 <name isRevamp="false">String</name>
 <password isRevamp="true">String</password>
 <gender isRevamp="false">0</gender>
 <birthday isRevamp="true">1967-08-13</birthday>
 <nation isRevamp="false">String</nation>
 <hometown isRevamp="false">String</hometown>
 <homeAddress isRevamp="false">String</homeAddress>
 <IDCard isRevamp="true">String</IDCard>
 <entranceDate isRevamp="true">1967-08-13</entranceDate>
 <schLen isRevamp="false">String</schLen>
 <grade isRevamp="true">String</grade>
 <specialty isRevamp="true">String</specialty>
 <depart isRevamp="true">String</depart>
 <phone isRevamp="true">无</phone>
 <photo isRevamp="false">D:/AB98J.jpg</photo>
</stud>

..................................>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
xsl文件

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <xsl:template match="/">
  <html>
   <head>
    <link rel="stylesheet" href="view.css"/>
   </head>
   <body>
    <!-- 表单 -->
    <form action="studUpdateAction.do" method="post">
     <table border="1" align="center" cellspacing="0" table-layout="fixed" width="600">
      <!--第1行: 表头 -->
      <tbody>
       <tr align="right" bgcolor="#FECD58">
        <td align="left" height="4" width="151" id="tdb">学号 :
              <xsl:for-each select="stud">
          <xsl:for-each select="@studNo">
           <xsl:value-of select="."/>
          </xsl:for-each>
         </xsl:for-each>
        </td>
        <td align="center" height="4" width="255" id="tdb">姓名 :
              <xsl:for-each select="stud">
          <xsl:for-each select="name">
           <xsl:apply-templates />
          </xsl:for-each>
         </xsl:for-each>
        </td>
        <td align="left" height="4" width="157" id="tdb">性别 :
              <xsl:for-each select="stud">
              <xsl:apply-templates select="gender" />
          
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第2行: 蓝色背景条 -->
       <tr bgcolor="#B5CB5C">
        <td colspan="3" width="151">学生个人基本信息 : </td>
       </tr>
       <!-- 第3行: 学号 -->
       <tr bgcolor="#EBF4B7">
        <td width="151">学号</td>
        <td width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="@studNo">
           <input name="studNo" value="" size="50" id="noinput" readonly="readonly">
            <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
           </input>
          </xsl:for-each>
         </xsl:for-each>
        </td>
        <td rowspan="7" width="157" align="center">
         <img border="0" width="120" height="150">
          <xsl:attribute name="src"><xsl:value-of select="stud/photo"/></xsl:attribute>
         </img>
        </td>
       </tr>
       <!-- 第4行:姓名 -->
       <tr bgcolor="#EBF4B7">
        <td width="151">姓名</td>
        <td width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="name">
           <xsl:if test="@isRevamp = 'true'">
            <input name="name" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="name" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第5行:密码 -->
       <tr bgcolor="#EBF4B7">
        <td width="151">密码</td>
        <td width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="password">
           <xsl:if test="@isRevamp = 'true'">
            <input name="password" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="password" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第6行:性别 -->
       <tr bgcolor="#EBF4B7">
        <td width="151">性别</td>
        <td width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="gender">
           <xsl:if test="@isRevamp = 'true'">
            <input name="gender" value="" size="50">
              <xsl:attribute name="value">
                <xsl:if test=".='0'">女</xsl:if>
                          <xsl:if test=".='1'">男</xsl:if>
                          </xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="gender" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value">
               <xsl:if test=".='0'">女</xsl:if>
                          <xsl:if test=".='1'">男</xsl:if>
                          </xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第7行:出生日期-->
       <tr bgcolor="#EBF4B7">
        <td width="151">出生日期</td>
        <td width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="birthday">
           <xsl:if test="@isRevamp = 'true'">
            <input name="birthday" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="birthday" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第8行:民族-->
       <tr bgcolor="#EBF4B7">
        <td width="151">民族</td>
        <td width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="nation">
           <xsl:if test="@isRevamp = 'true'">
            <input name="nation" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="nation" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第9行:籍贯-->
       <tr bgcolor="#EBF4B7">
        <td width="151">籍贯</td>
        <td width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="hometown">
           <xsl:if test="@isRevamp = 'true'">
            <input name="hometown" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="hometown" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!--第10行:家庭住址-->
       <tr bgcolor="#EBF4B7">
        <td width="151">家庭住址</td>
        <td colspan="2" width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="homeAddress">
           <xsl:if test="@isRevamp = 'true'">
            <input name="homeAddress" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="homeAddress" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第11行:身份证号码-->
       <tr bgcolor="#EBF4B7">
        <td width="151">身份证号码</td>
        <td colspan="2" width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="IDCard">
           <xsl:if test="@isRevamp = 'true'">
            <input name="IDCard" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="IDCard" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第12行:入学日期-->
       <tr bgcolor="#EBF4B7">
        <td width="151">入学日期</td>
        <td colspan="2" width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="entranceDate">
           <xsl:if test="@isRevamp = 'true'">
            <input name="entranceDate" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="entranceDate" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第13行:学制-->
       <tr bgcolor="#EBF4B7">
        <td width="151">学制</td>
        <td colspan="2" width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="schLen">
           <xsl:if test="@isRevamp = 'true'">
            <input name="schLen" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="schLen" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第14行:年级-->
       <tr bgcolor="#EBF4B7">
        <td width="151">年级</td>
        <td colspan="2" width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="grade">
           <xsl:if test="@isRevamp = 'true'">
            <input name="grade" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="grade" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第15行:专业-->
       <tr bgcolor="#EBF4B7">
        <td width="151">专业</td>
        <td colspan="2" width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="specialty">
           <xsl:if test="@isRevamp = 'true'">
            <input name="specialty" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="specialty" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第16行:系-->
       <tr bgcolor="#EBF4B7">
        <td width="151">系</td>
        <td colspan="2" width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="depart">
           <xsl:if test="@isRevamp = 'true'">
            <input name="depart" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="depart" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第17行:电话-->
       <tr bgcolor="#EBF4B7">
        <td width="151">电话</td>
        <td colspan="2" width="255">
         <xsl:for-each select="stud">
          <xsl:for-each select="phone">
           <xsl:if test="@isRevamp = 'true'">
            <input name="phone" value="" size="50">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
           <xsl:if test="@isRevamp = 'false'">
            <input name="phone" value="" size="50" id="noinput" readonly="readonly">
             <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
            </input>
           </xsl:if>
          </xsl:for-each>
         </xsl:for-each>
        </td>
       </tr>
       <!-- 第18行:照片 -->
       <input type="hidden" name="photo" value="" size="50" id="noinput" readonly="readonly">
         <xsl:attribute name="value"><xsl:value-of select="stud/photo"/></xsl:attribute>
       </input>
       <!-- 第19行:按钮 -->
       <tr bgcolor="#EBF4B7">
        <td align="center" colspan="3" width="151">
         <input type="submit" value="确定"/>
         <input type="reset" value="取消"/>
        </td>
       </tr>
      </tbody>
     </table>
    </form>
   </body>
  </html>
 </xsl:template>
 <xsl:template match="gender">
  <xsl:if test=".='0'">女</xsl:if>
  <xsl:if test=".='1'">男</xsl:if>
 </xsl:template>
</xsl:stylesheet>


--  作者:haiwei_wang
--  发布时间:12/15/2003 12:22:00 AM

--  
不知道你想知道的是什么,如果有什么问题可以研究....
我的qq: 15770732   ,每天半夜以后

email: haiwei_wang@tom.com


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
109.375ms