Namespace issues in InfoPath output form

M

Matt

Hi,

I'm a newbie at InfoPath, so please forgive me if I ask something dumb.

I have an InfoPath form I created, using an XML file. It works fine, but
when I save the filled-in form, it adds extra stuff in the XML file header.
Specifically, it adds a 'my' namespace, takes the namespace from the input
file and changes it to 'ns1', then sticks 'ns1:' in front of each element in
the output file.

Is there any way to get the output file to look like the input file? I've
looked for settings in the program, but with no success.

Thanks,
Matt
 
M

Matt Blank

Hello-
The 'my' namespace is automatically added to the XML file upon
saving... I can't recall why but there is a reason that it does it.
Here is the solution, snipped from http://www.InfoPathDev.com
----------------------
Prevent InfoPath From Autogenerating a Default Namespace Prefix
By Greg Collins, Thursday, October 07, 2004 1:13:41 PM

If you use a custom schema for your InfoPath form that has a target
namespace with no prefix defined, InfoPath will create a default prefix
for you following the pattern of: ns1, ns2, ... nsn. The "ns1" prefix
that InfoPath generates just stands for generic "namespace 1".

Here's what a schema root node looks like that will cause InfoPath to
autogenerate a target namespace prefix:

<xsd:schema targetNamespace="mynamespace"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="mynamespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

If you do not want InfoPath to autogenerate a prefix, you need to
specify your own target namespace prefix. Let's say you name the prefix
foo; now all of your form elements will be prefixed with foo instead of
ns1. Here's what that schema root node looks like:

<xsd:schema targetNamespace="mynamespace"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:foo="mynamespace">

If your preference is for your form elements to have no prefix at all,
you need to make sure you don't declare a target namespace. In XML
Schema, it is forbidden to have a prefixless namespace without a target
namespace. So your choice here is to remove completely remove both the
target namespace and the prefixless namespace. Here's what that schema
root node looks like with this change:

<xsd:schema elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
----------------------
Also, the 'ns1:' element tag that it places in front of every tag is
also standard. The group that you create in the data source is what is
appended to the tags. This is a way to view the data source hierarchy
for each tag. If you had two groups above that tag, there would be two
elements in front of the tag (in succession of decending order). This
cannot be eliminated without rearranging the data source to have no
groupings, with all the tags at the main level. You will still recieve
at least one tag from the main group because you cannot eliminate that
main group. Hope this helps.
Matt Blank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top