Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从XML架构生成表单密钥_Javascript_Xslt_Forms_Xsd - Fatal编程技术网

Javascript 从XML架构生成表单密钥

Javascript 从XML架构生成表单密钥,javascript,xslt,forms,xsd,Javascript,Xslt,Forms,Xsd,我想发送一条编码为application/x-www-form-urlencoded的消息,该消息由XML模式验证,因此我找到了一种使用XSLT从XML模式生成html表单的方法 xsd如下所示: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m="http://dongfang- china.com#" targetNa

我想发送一条编码为application/x-www-form-urlencoded的消息,该消息由XML模式验证,因此我找到了一种使用XSLT从XML模式生成html表单的方法

xsd如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m="http://dongfang-   china.com#" targetNamespace="http://dongfang-china.com#" elementFormDefault="qualified" attributeFormDefault="unqualified">

    <xs:complexType name="SwitchingSchedule">       
    <xs:sequence>
        <xs:element name="endDateTime" type="xs:dateTime">

        </xs:element>
        <xs:element name="reason" type="xs:string"> 


        </xs:element>
        <xs:element name="startDateTime" type="xs:dateTime">                                                         

        </xs:element>
    </xs:sequence>
</xs:complexType>
<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">
 <xsl:output method="html"/>
  <xsl:template match="xs:schema">
  <xsl:for-each select="xs:complexType/xs:sequence/xs:element">
    <br/>
   <label><xsl:value-of select="@name"/></label>
   <input type="text" name=""/> 

  </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

xslt如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m="http://dongfang-   china.com#" targetNamespace="http://dongfang-china.com#" elementFormDefault="qualified" attributeFormDefault="unqualified">

    <xs:complexType name="SwitchingSchedule">       
    <xs:sequence>
        <xs:element name="endDateTime" type="xs:dateTime">

        </xs:element>
        <xs:element name="reason" type="xs:string"> 


        </xs:element>
        <xs:element name="startDateTime" type="xs:dateTime">                                                         

        </xs:element>
    </xs:sequence>
</xs:complexType>
<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">
 <xsl:output method="html"/>
  <xsl:template match="xs:schema">
  <xsl:for-each select="xs:complexType/xs:sequence/xs:element">
    <br/>
   <label><xsl:value-of select="@name"/></label>
   <input type="text" name=""/> 

  </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>


结果是:

<br><label>endDateTime</label><input type="text"><br><label>reason</label><input type="text"><br><label>startDateTime</label><input type="text">

结束日期时间
原因
开始日期时间
但是我找不到从xsd设置输入名称的方法,或者我应该使用javascript吗

试试看:

<input type="text" name="{@name}"/> 
<input type="text" name="{@name}"/> 

(见附件)


顺便说一下,您可以使用
xs:annotation/xs:appInfo
添加有关外观更好的标签、上下文帮助等的信息

您有两个选择:

使用:


使用快捷方式(属性值模板):