Forum Stats

  • 3,781,163 Users
  • 2,254,485 Discussions
  • 7,879,599 Comments

Discussions

XML and ClassDomains

3004
3004 Member Posts: 204,171
I have a situation similar to the vcard example for embedded attributes.

My CustomClass1 is a subclass of Document. I also have CustomClass2 which is also a subclass of Document.

CustomClass1 has an attribute of type CustomClass2.

I have set up the XML for both class definitions, as well as an XML for the class domain of CustomClass2.

These XMLs have been uploaded successfully.

Now I want to write an XML to upload an instance for CustomClass1. How do I specify the attribute that references CustomClass2?

The VCard example never gives an actual example of an XML instance! Is the full sample code for vcard available yet?

Any help would be appreciated.


null

Comments

  • 3004
    3004 Member Posts: 204,171
    Since VCARDs are natively XML I do not have a XML rendition of a VCARD handy

    However here is a instance of a purchase order

    Below are the XML files that created the purchase order content type and the related content type and domains


    Hope this helps

    <?xml version="1.0" standalone="yes"?>
    <PurchaseOrder>
    <REFERENCE>AMILLER:20000328-091508137</REFERENCE>
    <REQUESTER>Angela B. Miller</REQUESTER>
    <USERID>amiller</USERID>
    <COSTCENTER>A10</COSTCENTER>
    <PONUMBER/>
    <SHIPPINGINSTRUCTIONS>
    <SHIPTONAME>George King</SHIPTONAME>
    <ADDRESS>500 Oracle Parkway MS 5op-12 Redwood Shores CA 94065</ADDRESS>
    <PHONE>650 506 7000</PHONE>
    </SHIPPINGINSTRUCTIONS>
    <SPECIALINSTRUCTIONS>Please Expidite this order</SPECIALINSTRUCTIONS>
    <REJECTION>
    <REJECTEDBY/>
    <COMMENTS/>
    </REJECTION>
    <ACTIONS>
    <ACTION>
    <ACTIONEDBY>eclark</ACTIONEDBY>
    <DATEACTIONED/>
    </ACTION>
    </ACTIONS>
    <LINEITEMS>
    <LINEITEM>
    <ITEMNUMBER>1</ITEMNUMBER>
    <QUANTITY>1</QUANTITY>
    <UNITPRICE>2999.0</UNITPRICE>
    <ITEMDESCRIPTION>Dell Laptop CPIx</ITEMDESCRIPTION>
    </LINEITEM>
    <LINEITEM>
    <ITEMNUMBER>2</ITEMNUMBER>
    <QUANTITY>2</QUANTITY>
    <UNITPRICE>299.0</UNITPRICE>
    <ITEMDESCRIPTION>Dell Battery</ITEMDESCRIPTION>
    </LINEITEM>
    <LINEITEM>
    <ITEMNUMBER>3</ITEMNUMBER>
    <QUANTITY>2</QUANTITY>
    <UNITPRICE>250.0</UNITPRICE>
    <ITEMDESCRIPTION>Dell Expansion Bay</ITEMDESCRIPTION>
    </LINEITEM>
    </LINEITEMS>
    </PurchaseOrder>

    Purchase Order Type Definition

    <?xml version="1.0" standalone="yes"?>
    <CLASSOBJECT>

    <NAME>PurchaseOrder</NAME>
    <SUPERCLASS REFTYPE="name">Document</SUPERCLASS>
    <DESCRIPTION>Internet Purchase Order</DESCRIPTION>
    <BEANCLASSPATH>ifs.demo.purchaseOrder.type.PurchaseOrder</BEANCLASSPATH>

    <ATTRIBUTES>
    <ATTRIBUTE>
    <NAME>Reference</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>64</DATALENGTH>
    </ATTRIBUTE>
    <ATTRIBUTE>
    <NAME>Requester</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>48</DATALENGTH>
    </ATTRIBUTE>
    <ATTRIBUTE>
    <NAME>UserID</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>32</DATALENGTH>
    </ATTRIBUTE>
    <ATTRIBUTE>
    <NAME>CostCenter</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>3</DATALENGTH>
    </ATTRIBUTE>
    <ATTRIBUTE>
    <NAME>Vendor</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>32</DATALENGTH>
    </ATTRIBUTE>
    <ATTRIBUTE>
    <NAME>PONumber</NAME>
    <DATATYPE>Integer</DATATYPE>
    </ATTRIBUTE>
    <ATTRIBUTE>
    <NAME>ShippingInstructions</NAME>
    <DATATYPE>PublicObject</DATATYPE>
    <CLASSDOMAIN REFTYPE="name">
    PurchaseOrderShippingInstructionsDomain
    </CLASSDOMAIN>
    </ATTRIBUTE>
    <ATTRIBUTE>
    <NAME>Rejection</NAME>
    <DATATYPE>PublicObject</DATATYPE>
    <CLASSDOMAIN REFTYPE="name">
    PurchaseOrderRejectionDomain
    </CLASSDOMAIN>
    </ATTRIBUTE>
    <ATTRIBUTE>
    <NAME>Actions</NAME>
    <DATATYPE>PublicObject_Array</DATATYPE>
    <CLASSDOMAIN REFTYPE="name">
    PurchaseOrderActionDomain
    </CLASSDOMAIN>
    </ATTRIBUTE>
    <ATTRIBUTE>
    <NAME>SpecialInstructions</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>2048</DATALENGTH>
    </ATTRIBUTE>
    <ATTRIBUTE>
    <NAME>LineItems</NAME>
    <DATATYPE>PublicObject_Array</DATATYPE>
    <CLASS DOMAIN REFTYPE="name">
    PurchaseOrderLineItemDomain
    </CLASSDOMAIN>
    </ATTRIBUTE>
    </ATTRIBUTES>
    </CLASSOBJECT>

    Purchase Order Action

    <?xml version="1.0" standalone="yes"?>
    <CLASSOBJECT>

    <NAME>PurchaseOrderAction</NAME>
    <SUPERCLASS REFTYPE="name">ApplicationObject</SUPERCLASS>
    <DESCRIPTION>Internet Purchase Order</DESCRIPTION>
    <BEANCLASSPATH>ifs.demo.purchaseOrder.type.PurchaseOrderAction</BEANCLASSPATH>
    <DATABASEOBJECTNAME>POActionHistory</DATABASEOBJECTNAME>

    <ATTRIBUTES>

    <ATTRIBUTE>
    <NAME>ActionedBy</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>32</DATALENGTH>
    </ATTRIBUTE>

    <ATTRIBUTE>
    <NAME>DateActioned</NAME>
    <DATATYPE>date</DATATYPE>
    </ATTRIBUTE>

    </ATTRIBUTES>

    </CLASSOBJECT>

    Purchase Order Action Domain

    <?xml version="1.0" standalone="yes"?>
    <CLASSDOMAIN>
    <NAME>PurchaseOrderActionDomain</NAME>
    <DOMAINTYPE>1</DOMAINTYPE>
    <CLASSES>
    <CLASS REFTYPE="name">PurchaseOrderaction</CLASS>
    </CLASSES>
    </CLASSDOMAIN>

    Purchase Order Rejection


    <?xml version="1.0" standalone="yes"?>
    <CLASSOBJECT>

    <NAME>PurchaseOrderRejection</NAME>
    <SUPERCLASS REFTYPE="name">ApplicationObject</SUPERCLASS>
    <DESCRIPTION>Internet Purchase Order</DESCRIPTION>
    <DATABASEOBJECTNAME>PORejection</DATABASEOBJECTNAME>
    <BEANCLASSPATH>ifs.demo.purchaseOrder.type.PurchaseOrderRejection</BEANCLASSPATH>

    <ATTRIBUTES>
    <ATTRIBUTE>
    <NAME>RejectedBy</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>32</DATALENGTH>
    </ATTRIBUTE>

    <ATTRIBUTE>
    <NAME>DateRejected</NAME>
    <DATATYPE>date</DATATYPE>
    </ATTRIBUTE>

    <ATTRIBUTE>
    <NAME>Comments</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>2048</DATALENGTH>
    </ATTRIBUTE>
    </ATTRIBUTES>
    </CLASSOBJECT>

    Purchase Order Rejection Domain

    <?xml version="1.0" standalone="yes"?>
    <CLASSDOMAIN>
    <NAME>PurchaseOrderRejectionDomain</NAME>
    <DOMAINTYPE>1</DOMAINTYPE>
    <CLASSES>
    <CLASS REFTYPE="name">PurchaseOrderRejection</CLASS>
    </CLASSES>
    </CLASSDOMAIN>

    Purchase Order Shipping Instruction

    <?xml version="1.0" standalone="yes"?>
    <CLASSOBJECT>

    <NAME>PurchaseOrderShippingInstructions</NAME>
    <SUPERCLASS REFTYPE="name">ApplicationObject</SUPERCLASS>
    <DESCRIPTION>Internet Purchase Order</DESCRIPTION>
    <DATABASEOBJECTNAME>POShipInst</DATABASEOBJECTNAME>
    <BEANCLASSPATH>ifs.demo.purchaseOrder.type.PurchaseOrderShippingInstructions</BEANCLASSPATH>

    <ATTRIBUTES>
    <ATTRIBUTE>
    <NAME>ShipToName</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>48</DATALENGTH>
    </ATTRIBUTE>

    <ATTRIBUTE>
    <NAME>Address</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>512</DATALENGTH>
    </ATTRIBUTE>

    <ATTRIBUTE>
    <NAME>Phone</NAME>
    <DATATYPE>String</DATATYPE>
    <DATALENGTH>32</DATALENGTH>
    </ATTRIBUTE>
    </ATTRIBUTES>
    </CLASSOBJECT>

    Purchase Order Shipping Instruction Domain


    <?xml version="1.0" standalone="yes"?>
    <CLASSDOMAIN>
    <NAME>PurchaseOrderShippingInstructionsDomain</NAME>
    <DOMAINTYPE>1</DOMAINTYPE>
    <CLASSES>
    <CLASS REFTYPE="name">PurchaseOrderShippingInstructions</CLASS>
    </CLASSES>
    </CLASSDOMAIN>

    Purchase Order Line Item

    <?xml version="1.0" standalone="yes"?>
    <CLASSOBJECT>

    <NAME>PurchaseOrderLineItem</NAME>
    <SUPERCLASS REFTYPE="name"&g t;ApplicationObject</SUPERCLASS>
    <DESCRIPTION>Internet Purchase Order</DESCRIPTION>
    <BEANCLASSPATH>ifs.demo.purchaseOrder.type.PurchaseOrderLineItem</BEANCLASSPATH>
    <DATABASEOBJECTNAME>POLineItem</DATABASEOBJECTNAME>

    <ATTRIBUTES>
    <ATTRIBUTE>
    <NAME>ItemNumber</NAME>
    <DATATYPE>integer</DATATYPE>
    </ATTRIBUTE>

    <ATTRIBUTE>
    <NAME>ItemDescription</NAME>
    <DATATYPE>string</DATATYPE>
    <DATALENGTH>128</DATALENGTH>
    </ATTRIBUTE>

    <ATTRIBUTE>
    <NAME>Quantity</NAME>
    <DATATYPE>integer</DATATYPE>
    </ATTRIBUTE>

    <ATTRIBUTE>
    <NAME>UnitPrice</NAME>
    <DATATYPE>double</DATATYPE>
    </ATTRIBUTE>

    </ATTRIBUTES>
    </CLASSOBJECT>

    Purhcase Order Line Item Domain

    <?xml version="1.0" standalone="yes"?>
    <CLASSDOMAIN>
    <NAME>PurchaseOrderLineItemDomain</NAME>
    <DOMAINTYPE>1</DOMAINTYPE>
    <CLASSES>
    <CLASS REFTYPE="name">PurchaseOrderLineItem</CLASS>
    </CLASSES>
    </CLASSDOMAIN>


    null
  • 3004
    3004 Member Posts: 204,171
    Thanks, that helped a bit.

    Let me get this right...

    When creating a new instance of my CustomClass1, my XML for the instance needs to contain a tagged section named CustomClass2, with the attributes that I want. Then when I upload the XML file, I assume that both the CustomClass1 instance and its CustomClass2 instance will both be created. Is that correct?

    What if I an instance of CustomClass2 already exists and I want to create an instance of CustomClass1, that references the existing CustomClass2? Can that be done via XML?

  • 3004
    3004 Member Posts: 204,171
    To answer your first question you're right, If the instance of customclass1 contains an instance of customclass2 then both would be created when you load the file. The appropraite relationships would also be created.

    To answer you second question

    You can have an xml file where an instance of one custom class contains a reference to an instance of another custom class. The codasyl here is that you have to able to uniquely identify the instance of customclass2 you want to reference. The syntax is as follows

    (Sorry to swap to a different example)

    I have a pencil object. The Pencil object has an attribute PencilColor which is defined to be an reference to an object of type color.

    The following code would create a in instance of Pencil Object with a reference to the existing yellow color object

    <PencilObject>
    <PencilName>Yellow Pencil</PencilName>
    <PencilLength>12</PencilLength>
    <PencilColor>
    <Ref Type="ColorName"> Yellow </Ref>
    </PencilColor>
    <FolderPath>.</FolderPath>
    <Name>Yellow.Pencil</Name>
    </PencilObject>

    In this case the classobject referenced by the classdomain used to define the attribute pencilColor has a unqiue attribute ColorName.

    Because this condition is true I can unqiuely identify an instace of Color via the ColorName attribute and consquently I can use this to reference an instance of color when creating an instance of Pencil
  • 3004
    3004 Member Posts: 204,171
    Thanks Mark, it's exactly what I was missing.
    I appreciate your continued support.
This discussion has been closed.