Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optional Field/element in output
Message
From
28/07/2007 10:16:32
 
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
01244346
Message ID:
01244355
Views:
21
>>>>Yes, Borislav - thanks, I know that, but I would like the line to disappear from the output, ie no tag field
>>>>
>>>>Based on a condition I have to output either A1 or A2, but not both
>>>
>>>Why?
>>
>>Below a part of a schema
>>
>>
>>- <xs:complexType>
>>- <xs:sequence>
>>- <xs:choice>
>>  <xs:element ref="QUARTER" />
>>  <xs:element ref="MONTH" />
>>  </xs:choice>
>>  <xs:element ref="YEAR" />
>>  </xs:sequence>
>>  </xs:complexType>
>>
>>
>>So I have to produce
>>
>>
>>either
>>
>><PERIOD>
>>   <QUARTER>1</QUARTER>
>>   <YEAR>2007</YEAR>
>></PERIOD>
>>
>>or
>>
>><PERIOD>
>>   <MONTH>3</MONTH>
>>   <YEAR>2007</YEAR>
>></PERIOD>
>>
>>
>
>Is this works for you:
>
>CLEAR
>SET ASSERTS ON
>create cursor period ;
>    (QUARTER        c(10), ;
>     YEAR           c(10) ;
>    )
>
>create cursor PERIOD1 ;
>    (MONTH        c(10), ;
>     YEAR         c(10) ;
>    )
>
>    insert into PERIOD values('1', '10')
>    insert into PERIOD values('2', '20')
>
>    insert into PERIOD1 values('11', '11')
>    insert into PERIOD1 values('12', '21')
>
>    local xml, i, s
>    xml = createobject('xmladapter')
>
>    =xml.AddTableSchema('period')
>    =xml.AddTableSchema('PERIOD1',.T.,STRCONV([PERIOD],12))
>    xml.xmlSchemalocation=''
>    ? xml.ToXml('s',[],.t.)
>
>You have both but if you don't use case sensitive parsing after that :-)

I thought that xml was case sensitive.

But anyway, there's a solution

It works with the example below. Strange thing is that the null is the first thing I tried and I had .NULL. in the output
I have to figure out why - but I'll find that
create cursor test ;
	(	need_a1	L, ;
		a0		c(10), ;
		a1		 c(10) null , ;
		a2		 c(10) null ;
	)
	
	insert into test values( TRUE, '1', '10', null)
	insert into test values( FALSE, '2', null, '21')
	
	local xml, i, s, obj
	xml = createobject('xmladapter')
	
	=xml.AddTableSchema('test')
	xml.xmlSchemalocation=''

	i = m.xml.Tables(1).Fields.GetKey(strconv('need_a1', 12))
	assert !empty(m.i)
	= m.xml.Tables(1).Fields.Remove(m.i)
	
	
	= m.xml.ToXml('s')
	?s
<VFPDataSet>
	<test>
		<a0>1</a0>
		<a1>10</a1>
	</test>
	<test>
		<a0>2</a0>
		<a2>21</a2>
	</test>
</VFPDataSet>
thanks for the help
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform