October 2004 - Posts - Greg Collins

InfoPath Dev

This Blog


Greg Collins

October 2004 - Posts

  • Prevent InfoPath From Autogenerating a Default Namespace Prefix

    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 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">

    ©2004 Greg Collins. All rights reserved. Licensed to Autonomy Systems, LLC for display on InfoPathDev.com.

Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.