以文本方式查看主题

-  计算机科学论坛  (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=41602)


--  作者:lango2006
--  发布时间:12/25/2006 4:32:00 PM

--  请教 怎么样取到 属性值
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="control.xslt"?>
<control xmlns="http://my-company.com/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://my-company.com/namespace
control.xsd"> 
 <Glycohemoglobin value1="djfkjgk">
 <Result>Result</Result>
 
 </Glycohemoglobin>
 </control>


<?xml version="1.0" encoding="UTF-8"?>
<HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  <BODY>
  <TABLE border="0" cellspacing="0" >
   <form method="post" action="">
    <xsl:for-each select="control">
   
     <TR>
      <TD width="90" align="right">Glycohemoglobin</TD>
      <TD width="200" >
       <input type="text" name="str" size="20">
        <xsl:attribute name="value"><xsl:value-of select="Glycohemoglobin[@value1]"/></xsl:attribute>
       </input>
      </TD>
     </TR>
     
    
    </xsl:for-each>
   </form>
  </TABLE>
 </BODY>
</HTML>

怎么样才能取出来 @value1 $value不行


--  作者:Qr
--  发布时间:12/25/2006 5:01:00 PM

--  
<xsl:value-of select="Glycohemoglobin/@value1"/>
--  作者:lango2006
--  发布时间:12/25/2006 5:20:00 PM

--  
谢谢
<Glycohemoglobin value1="djfkjgk">
怎么样判断 Glycohemoglobin 这个元素存在
--  作者:Qr
--  发布时间:12/25/2006 5:29:00 PM

--  
<xsl:if test="count(Glycohemoglobin) &gt; 0">存在</xsl:if>

<xsl:when test="Glycohemoglobin">存在</xsl:when>好象也可以


--  作者:lango2006
--  发布时间:12/25/2006 5:40:00 PM

--  
方法未知。count()
name()也不支持 怎么样才能支持恩,头怎么写我只写了这个<?xml version="1.0" encoding="UTF-8"?>
xmlspy 生成的我用不了
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">
 <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<html></html></xsl:stylesheet>
说什么可能不包括html


[此贴子已经被作者于2006-12-25 18:20:22编辑过]

--  作者:Qr
--  发布时间:12/26/2006 12:12:00 PM

--  
<?xml version="1.0" encoding="UTF-8"?>
<HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  <BODY>
  <TABLE border="0" cellspacing="0" >
   <form method="post" action="">
    <xsl:for-each select="control">
   
     <TR>
      <TD width="90" align="right">Glycohemoglobin</TD>
      <TD width="200" >
       <input type="text" name="str" size="20">
        <xsl:attribute name="value"><xsl:value-of select="Glycohemoglobin/@value1"/></xsl:attribute>
       </input>
      </TD>
     </TR>
     
    <xsl:choose><xsl:when test="Glycohemoglobin">存在</xsl:when></xsl:choose>
    </xsl:for-each>
   </form>
  </TABLE>
</BODY>
</HTML>


--  作者:lango2006
--  发布时间:12/26/2006 1:58:00 PM

--  
不是这个问题 ,我去掉xml的校验就好了
--  作者:lango2006
--  发布时间:12/26/2006 2:15:00 PM

--  
xmlspy 自动生产的xsd的名称空间不行,xml不出来东西,自己写一个简单就好了

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