InfoPath 系列:了解INFOPATH XSN文件的格式(1)

 这一章我来为大家介绍一下INFOPATH的文件格式。前面几篇中我们用到例子在发布之后无论是客户端版本的还是WEB版本的都会生成一个xsn文件。这个文件扩展名是INFOPATH文件的扩展名,但我们用其它软件一样可以打开它,下面我们就来看看这里面到底有什么。

      首先,我们找到之前生成的XSN文件,将它的扩展名改为.zip。然后用任何一种解压工具将其解压,解压后所得到的文件如下图所示:

      image

      下面就一个一个来看,

      manifest.xsf:顾名思义,就是一个清单,先看看里面都有什么东西吧,打开这个文件后除了头部的各种声明信息外接下来就是包内的文件信息:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
< XSF:FILE myschema.xsd?, name = "template.xml" >,<? xml:namespace prefix = xsf />< xsf:file name = "view1.xsl" >]; html-script: false; light: false; ruler: false; smart-tabs: true; tab-size: 4; toolbar: true;">< xsf:package >
        < xsf:files >
            < xsf:file name = "myschema.xsd" >
                < xsf:fileProperties >
                    < xsf:property name = "namespace" type = "string" value = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-05-17T14:43:28" ></ xsf:property >
                    < xsf:property name = "editability" type = "string" value = "full" ></ xsf:property >
                    < xsf:property name = "rootElement" type = "string" value = "Form" ></ xsf:property >
                    < xsf:property name = "useOnDemandAlgorithm" type = "string" value = "yes" ></ xsf:property >
                </ xsf:fileProperties >
            </ xsf:file >
            < xsf:file name = "template.xml" ></ xsf:file >
            < xsf:file name = "sampledata.xml" >
                < xsf:fileProperties >
                    < xsf:property name = "fileType" type = "string" value = "sampleData" ></ xsf:property >
                </ xsf:fileProperties >
            </ xsf:file >
            < xsf:file name = "view1.xsl" >
                < xsf:fileProperties >
                    < xsf:property name = "lang" type = "string" value = "2052" ></ xsf:property >
                    < xsf:property name = "mode" type = "string" value = "1" ></ xsf:property >
                    < xsf:property name = "componentId" type = "string" value = "31" ></ xsf:property >
                    < xsf:property name = "xmlToEditName" type = "string" value = "11" ></ xsf:property >
                </ xsf:fileProperties >
            </ xsf:file >
        </ xsf:files >
    </ xsf:package >

?
1
<? xml:namespace prefix = xsf />< xsf:file myschema.xsd?, name = "template.xml" >
?
1
<? xml:namespace prefix = xsf />< xsf:file myschema.xsd?, name = "template.xml" >< xsf:file name = "view1.xsl" >

      这里声明的文件在上面的列表中都可以看到,这一部分就是用来声明这个xsn文件的组成部分的。接下来是一些扩展信息,例如改xsn的视图信息、发布信息、缓存信息、xsn文件信息等。代码如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
< xsf:extensions >
        < xsf:extension name = "SolutionDefinitionExtensions" >
            < xsf2:solutionDefinition runtimeCompatibility = "client server" allowClientOnlyCode = "no" >
                < xsf2:offline openIfQueryFails = "yes" cacheQueries = "yes" ></ xsf2:offline >
                < xsf2:viewsExtension >
                    < xsf2:viewExtension ref = "视图 1" designMode = "normal" clientOnly = "no" >
                        < xsf2:xmlToEditExtension ref = "field1_1" allowLinkedImages = "yes" excludeEmbeddedImages = "yes" ></ xsf2:xmlToEditExtension >
                        < xsf2:xmlToEditExtension ref = "field2_2" allowLinkedImages = "yes" excludeEmbeddedImages = "yes" ></ xsf2:xmlToEditExtension >
                        < xsf2:xmlToEditExtension ref = "LeaderComnts_5" allowLinkedImages = "yes" excludeEmbeddedImages = "yes" ></ xsf2:xmlToEditExtension >
                        < xsf2:xmlToEditExtension ref = "ManagerComnts_6" allowLinkedImages = "yes" excludeEmbeddedImages = "yes" ></ xsf2:xmlToEditExtension >
                    </ xsf2:viewExtension >
                </ xsf2:viewsExtension >
                < xsf2:server formLocale = "zh-CN" isPreSubmitPostBackEnabled = "no" isMobileEnabled = "no" ></ xsf2:server >
                < xsf2:solutionPropertiesExtension branch = "share" >
                    < xsf2:share formName = "请假申请表Publish" path = "C:\Users\Weiwei\Desktop\infopath\请假申请表Publish.xsn" accessPath = "C:\Users\Weiwei\Desktop\infopath\请假申请表Publish.xsn" ></ xsf2:share >
                </ xsf2:solutionPropertiesExtension >
            </ xsf2:solutionDefinition >
        </ xsf:extension >
    </ xsf:extensions >

     

      接下来的是上面定义的视图信息的具体描述,这里定义了绑定和未绑定的控件,也将mainpane指向了xsl文件,通过xsl文件可以将界面呈现出来。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
< xsf:views default = "视图 1" >
        < xsf:view name = "视图 1" caption = "视图 1" >
            < xsf:editing >
                < xsf:xmlToEdit name = "field1_1" item = "/my:Form/my:Reason" >
                    < xsf:editWith type = "rich" maxLength = "1" component = "xField" ></ xsf:editWith >
                </ xsf:xmlToEdit >
                < xsf:xmlToEdit name = "field2_2" item = "/my:Form/my:WhereToGo" >
                    < xsf:editWith type = "rich" maxLength = "1" component = "xField" ></ xsf:editWith >
                </ xsf:xmlToEdit >
                < xsf:xmlToEdit name = "LeaderComnts_5" item = "/my:Form/my:LeaderComnts" >
                    < xsf:editWith type = "rich" maxLength = "1" component = "xField" ></ xsf:editWith >
                </ xsf:xmlToEdit >
                < xsf:xmlToEdit name = "EndDate_11" item = "/my:Form/my:EndDate" >
                    < xsf:editWith proofing = "no" autoComplete = "no" component = "xField" ></ xsf:editWith >
                </ xsf:xmlToEdit >
                < xsf:xmlToEdit name = "StartDate_10" item = "/my:Form/my:StartDate" >
                    < xsf:editWith proofing = "no" autoComplete = "no" component = "xField" ></ xsf:editWith >
                </ xsf:xmlToEdit >
                < xsf:xmlToEdit name = "ManagerComnts_6" item = "/my:Form/my:ManagerComnts" >
                    < xsf:editWith type = "rich" maxLength = "1" component = "xField" ></ xsf:editWith >
                </ xsf:xmlToEdit >
            </ xsf:editing >
            < xsf:mainpane transform = "view1.xsl" ></ xsf:mainpane >
            < xsf:unboundControls >
                < xsf:button name = "CTRL31_5" ></ xsf:button >
            </ xsf:unboundControls >
        </ xsf:view >
    </ xsf:views >

      unboundControls定义了没有进行数据绑定的控件,也就是表单中的提交按钮。

      接下来的两项是关于schema和命名空间的设置:

?
1
2
3
4
5
6
< xsf:applicationParameters application = "InfoPath Design Mode" >
        < xsf:solutionProperties lastOpenView = "view1.xsl" fullyEditableNamespace = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-05-17T14:43:28" ></ xsf:solutionProperties >
    </ xsf:applicationParameters >
    < xsf:documentSchemas >
        < xsf:documentSchema rootSchema = "yes" location = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-05-17T14:43:28 myschema.xsd" ></ xsf:documentSchema >
    </ xsf:documentSchemas >

      然后是对于初始化数据的设置,也就是新打开一个表单的时候数据源的数据是什么状态,从下面的设置可以看出,初始化数据是指向了template.xml文件。

?
1
2
3
< xsf:fileNew >
        < xsf:initialXmlDocument caption = "请假申请表Publish" href = "template.xml" ></ xsf:initialXmlDocument >
    </ xsf:fileNew >

      最后是关于提交选项的定义,不知道大家是否还记得之前表单中关于提交的设置项,可以参照前一篇博文来查看提交项的定义。

?
1
2
3
4
5
6
7
8
< xsf:submit caption = "提交" disableMenuItem = "no" onAfterSubmit = "close" showStatusDialog = "yes" >
        < xsf:successMessage >请假申请已提交,请等待审批。</ xsf:successMessage >
        < xsf:errorMessage >由于出现错误,无法提交表单。</ xsf:errorMessage >
        < xsf:davAdapter name = "主提交" submitAllowed = "yes" overwriteAllowed = "no" >
            < xsf:folderURL value = "http://172.17.9.168/Shared%20Documents/" ></ xsf:folderURL >
            < xsf:fileName value = "concat(my:Department, &quot;-&quot;, my:FullName, &quot;的请假申请单&quot;)" valueType = "expression" ></ xsf:fileName >
        </ xsf:davAdapter >
    </ xsf:submit >

      通过上面的了解我们发现,XSN文件实际是一个ZIP包,表单中使用的元素及表单设置都被压缩到了这个包里,而manifest是这些资源的目录,也是表单的配置文件。下一篇我会为大家讲解另外几个文件的作用。感谢大家的支持,请大家继续关注我的博客,谢谢。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值