XForms/提交中更改命名空间
外观
< XForms
您希望控制在提交中处理命名空间前缀的方式。
我们将使用提交的includenamespaceprefixes属性。
XForms 1.1 规范允许用户更改提交元素中处理命名空间前缀的方式。
以下是如何将includenamespaceprefixes属性用于提交元素的示例。
<xf:submission action="http://example.com/submit"
method="post" id="submit"
includenamespaceprefixes=""/>
<xf:submission action="http://example.com/submit"
method="post" includenamespaceprefixes="#default"/>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:task="http://www.example.com/task"
task:dummy="dummy">
<head>
<title>Test of XForms Submission Namespace Inclusion</title>
<style type="text/css">
<![CDATA[
@namespace xf url("http://www.w3.org/2002/xforms");
body {font-family:Helvetica, sans-serif;}
.block-form xf|input { display: block; margin: 1ex; }
.block-form xf|label {display: inline-block; width: 15ex; float: left; text-align: right; margin-right: 1ex; font-weight: bold;}
]]>
</style>
<xf:model>
<xf:instance src="input-default-ns.xml" id='save-data'/>
<xf:submission id="submit-std"
action="https://127.0.0.1:8080/exist/rest/db/test/xforms/submission-tests/save-new.xq"
method="post"/>
<xf:submission id="submit-null"
action="https://127.0.0.1:8080/exist/rest/db/test/xforms/submission-tests/save-new.xq"
method="post"
includenamespaceprefixes=""/>
<xf:submission id="submit-default"
action="https://127.0.0.1:8080/exist/rest/db/test/xforms/submission-tests/save-new.xq"
method="post"
includenamespaceprefixes="#default"/>
</xf:model>
</head>
<body>
<h1>Submit Test</h1>
<div class="block-form">
<xf:input ref="instance('save-data')/task:id">
<xf:label>ID: </xf:label>
</xf:input>
<xf:input ref="task:task-name">
<xf:label>Name: </xf:label>
</xf:input>
<xf:input ref="task:task-description">
<xf:label>Description: </xf:label>
</xf:input>
</div>
<xf:submit submission="submit-std">
<xf:label>Without Attribute</xf:label>
</xf:submit>
<xf:submit submission="submit-null">
<xf:label>With Attribute Null</xf:label>
</xf:submit>
<xf:submit submission="submit-default">
<xf:label>With Default Namespace</xf:label>
</xf:submit>
</body>
</html>
<task xmlns="http://www.example.com/task">
<task:id>123</task:id>
<task-name>Task Name</task-name>
<task-description>Task Description</task-description>
</task>
<task:task xmlns:task="http://www.example.com/task">
<task:task:id>123</task:id>
<task:task-name>Task Name</task:task-name>
<task:task-description>Task Description</task:task-description>
</task:task>