Jump to content

Recommended Posts

I need to build XML for a line item.

here is the schema:

<xs:simpleType name="emptyString">
	<xs:restriction base="xs:string">
		<xs:enumeration value="" />
	</xs:restriction>
</xs:simpleType>

<xs:simpleType name="priceValue">
	<xs:restriction base="xs:decimal">
		<xs:totalDigits value='10'/>
		<xs:fractionDigits value='2'/>
		<xs:minInclusive value='0'/>
		<xs:maxInclusive value='99999999.99'/>
	</xs:restriction>
</xs:simpleType>


<xs:simpleType name="lineItemType">
	<xs:union memberTypes="priceValue emptyString" />
</xs:simpleType>


<xs:element name="lineItem">
	<xs:complexType>
		<xs:simpleContent>
			<xs:extension base="lineItemType">
				<xs:attribute name="quantity" type="xs:unsignedInt" use="required"/>
				<xs:attribute name="productID" type="xs:string"/>
				<xs:attribute name="owned" type="booleanInt"/>
				<xs:attribute name="productName" type="xs:string"/>
				<xs:attribute name="productCampaignResourceURL" type="resourceURI"/>
				<xs:attribute name="lineItemStatus" type="xs:string"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
</xs:element>

<xs:element name="lineItems">
  <xs:complexType>
    <xs:sequence>
		<xs:element ref="lineItem" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

 

My XML doesnt comply. I've never dealth with XML unions and am kind of confused. ANY help would be greatly appreciated.

 

	   
<lineItems>
<lineItem id="1">
		<quantity>1</quantity>
		<productId>$productID</productId>
		<owned>0</owned>
</lineItem>
</lineItems>

 

I just need to figure out how to input a lineItem appropriately. Having major issues getting the API to accept my request just because of the XML. Point me in the right direction and ill be out of your hair! =)

Link to comment
https://forums.phpfreaks.com/topic/238584-create-xml-from-schema-with-union/
Share on other sites

Can you show the full schema and full XML?

 

Edit: For what it's worth here are a few problems I can see:

1. quantity/owned/etc. should be attributes (not child elements)

2. productId should be productID

3. the id attribute isn't allowed (in the partial schema you gave)

 

As for the union in there, all it means is that the lineItem can contain either some text (a price between 0 and 99999999.99) or no text.

 

Thanks

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.