minOccurs=0 for Int type - InfoPath Dev
in

InfoPath Dev

minOccurs=0 for Int type

Last post 05-05-2005 12:34 PM by Agni Jonnalagadda. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-04-2005 06:55 AM

    minOccurs=0 for Int type

    I'm a newbie in Infopath.

    I've created a small webservice with Visual Basic.Net for comunicate with an Access DB.

    In the VB Code there is a Type called "Census" like this:


    Public Class Census
    Public ID as Int32
    Public DateBirth as Date
    Public Name as String
    End Class


    If I look to the WSDL it seems like this:


    <s:complexType name="Census">
    <s:sequence>
    <s:element minOccurs="1" maxOccurs="1" name="ID" type="s:int"/>
    <s:element minOccurs="1" maxOccurs="1" name="DateBirth" type="s:dateTime"/>
    <s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string"/>
    </s:sequence>
    </s:complexType>


    I would like that minOccurs for ID and DateBirth is 0 not 1 so that in Infopath I'm not obliged to insert a value for it. Alternatively I need a way to obviate this problem

    How can I do this??

    Thanks for replying and excuse me for my bad english.
  • 05-04-2005 09:09 PM In reply to

    Re: minOccurs=0 for Int type

    Hi fratellino, Welcome tot he Board!
    Minoccurs "0" does not mean that it is a compulsory field, It means that the total number of occurences of that element can be "0" i.e, the element can be or Cannot be there in the XML.
    Usually "integer" and "datetime" fields are made compulsory in the Infopath, to override this you can have "nillable" attribute set on Elements with "integer" and "DateTime" types.
    So your element can look like this
    <s:element minOccurs="1" maxOccurs="1" name="ID" type="s:int" nillable="true"/>

    and you need to set "xsi:nil='true'" in xml
    <DateBirth xsi:nil="true"></DateBirth>.

    Hope this helps!




    Agni
    InfoPathDev India
  • 05-04-2005 11:44 PM In reply to

    Re: minOccurs=0 for Int type

    Thanks for replying.

    the xml is not generate by me, but auto-generated by the .asmx file builded with Visual Basic.net
    So I can't edit this values, or if I can I don't know how.

    Andrea
  • 05-05-2005 12:34 PM In reply to

    Re: minOccurs=0 for Int type

    You can edit Schema file and have a "nillable" attribute on it. You can also add "xsi:nil" attribute to a node. Here is a way how to do it,

    private void setNil(IXMLDOMNode oNode) //oNode is your Node for which you dont want to enter a value
    {
    IXMLDOMElement oElement = (IXMLDOMElement)oNode;
    if(null != oElement.getAttribute("xsi:nil"))
    {
    // Create xsi:nil attribute with the proper namespace.
    IXMLDOMAttribute oNil = (IXMLDOMAttribute)oNode.ownerDocument.createNode((int)DOMNodeType.NODE_ATTRIBUTE, "xsi:nil", "http://www.w3.org/2001/XMLSchema-instance");
    oNil.text = "true";
    //Set the "xsi:nil" attribute to the node
    oElement.setAttributeNode(oNil);
    }
    }

    Hope this helps!

    Agni
    InfoPathDev India
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.