Changing default ns1 namespace prefix

I

I. Fuchs

I am having a great deal of difficulty attempting to eliminate the ns1
namespace prefixes that InfoPath applies and I can't seem to find any
documentation that addresses this satisfactorily (I have in front of me the
"Support and Troubleshooting for XML Schemas in InfoPath 2003")

Below is the test schema that I am using. The default xmlns is declared as
"xmlns="http://www.xmlassociates.com/namespacetest" and there is a target
namespace declaration of
targetNamespace="http://www.xmlassociates.com/namespacetest" and
elementFormDefault="qualified">

However when you save a document based on this schema in InfoPath, all of
the elements have the ns1 prefix. I even went into the script editor and
deleted the ns1 prefix in the namespace section but this did not fix the
problem. I would greatly appreciate any assistance with this.

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.xmlassociates.com/namespacetest"
targetNamespace="http://www.xmlassociates.com/namespacetest"
elementFormDefault="qualified">
<xsd:element name="Options">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ProductType" type="ProductTypeType"/>
<xsd:element name="PutCall" type="PutCallType"/>
<xsd:element name="OptionStyle" type="OptionStyleType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ProductTypeType">
<xsd:sequence>
<xsd:element name="Option">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="O"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="PutCallType">
<xsd:choice>
<xsd:element name="Put">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="P"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Call">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="C"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Other">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="M"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="Unknown">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="X"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="OptionStyleType">
<xsd:choice>
<xsd:element name="American">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="A"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="European">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="E"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:schema>


<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution
solutionVersion="1.0.0.7" productVersion="11.0.6357" PIVersion="1.0.0.0"
href="file:///C:\Documents%20and%20Settings\Ira%20Fuchs\Desktop\namespacetest.xsn"
name="urn:schemas-microsoft-com:eek:ffice:infopath:namespacetest:http---www-xmlassociates-com-namespacetest"
language="en-us" ?><?mso-application progid="InfoPath.Document"?><ns1:Options
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns1="http://www.xmlassociates.com/namespacetest"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
<ns1:productType>
<ns1:Option>O</ns1:Option>
</ns1:productType>
<ns1:putCall>
<ns1:put>P</ns1:put>
</ns1:putCall>
<ns1:OptionStyle>
<ns1:American>A</ns1:American>
</ns1:OptionStyle>
</ns1:Options>
 
M

Matthew Blain \(Serriform\)

Why do you care? The namespace prefix can be anything, and an XML parser
should use the namespace itself, not the prefix which happens to be assigned
to it. (Of course, there are some old and buggy ones which don't really
support namespaces).

There's some old threads in this newsgroup on using no namespace prefix at
all for config files, I know I posted on them.

--Matthew Blain
http://tips.serriform.com/
http://www.microsoft.com/mspress/books/7128.asp
 
I

I. Fuchs

Hi Mathew,

Thank you for your post to my query. You are correct from the perspective of
the behavior of a compliant parser. However your response skirts two valid
concerns - one, why does InfoPath assign a prefix to all objects in an
instant document if a default namespace and target namespace are present in a
source schema and two, it should not be assumeed that the XML being generated
from one application is going to be pre-processed by an XML parser when used
by another application. While this contradicts the value of using XM in the
first place, it is a fact that I have been confronted with more than once, as
there are numerous occasions where people are working quick and dirty fixes
to process XML (as was the case with Torsten Hensel whom you replied to).
Consequently, it is useful to know how to control how InfoPath assigns the
namespace prefixes.

Below is the schema declaration for a FIXML schema that does not specify a
qualified namespace prefix in its default and target namespace and InfoPath
is assigning "ns prefixes (xmlns:ns1="http://www.fixprotocol.org/FIXML-4-4"
xmlns:ns2="http://www.fixprotocol.org/fixml/metadata.xsd").
<xs:schema xmlns="http://www.fixprotocol.org/FIXML-4-4"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.fixprotocol.org/FIXML-4-4"
elementFormDefault="qualified" attributeFormDefault="unqualified">

I have found that if I extract the files from the XSN file and replace the
ns1 prefix with another prefix in the manifest file and then open the
manifest in design mode the instance document generated by the form will have
the new prefixes. However if I omit the prefix altogether InfoPath again
supplies the ns1 prefix in the instance document. I have also edited out the
ns1 prefix in the default script but that has nad no effect. Doing an XSL
transform on Save is clumsy andr inferring a schema from an existing XML
document is not an option when you are working with very large
data-dictionary style schemas such as fixml or fpML.

This should be a configurable parameter.

Ira Fuchs
 
B

Brian Teutsch [MSFT]

I think you'll get this answer in other ways, but for the benefit of the
community here's what I dug up with the gurus.

Unfortunately, there's no workaround for this in the Designer. You can
hand-modify all the solution files (manifest.xsf, template.xml, view.xsl,
etc) to remove the prefix, but you won't be able to roundtrip the solution
in the Designer again.



This isn't to say you can't have XML without a namespace, just that InfoPath
is insistent on the target namespace be used if it is specified.



Thanks,

Brian
 

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