Bug in XmlTextWriter.WriteString ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

Bug description: calling XmlTextWriter.WriteString with a one-character long argument could have no effect (nothing is written)

Workaround: use WriteRaw or insert a white space before

Circumstances: I could not reproduce in a standalone program. In my complete application, the attached XML should be generated, but instead of

<c:Primitive c:type="decimal">6</c:Primitive

I ge

<c:Primitive c:type="decimal" />

The complete XML is

<o:MatrixVersionXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:c="uri:adastra.criteria" xmlns:o="uri:cetelem.otis"><o:Parameters><o:Comment /><o:ResponsiblePerson /><o:SendDate>2004-03-18T10:33:52.1434992+01:00</o:SendDate><o:ControlGroupSizeDefinitionMethod>Absolute</o:ControlGroupSizeDefinitionMethod><o:ControlGroupSize>1000</o:ControlGroupSize><o:ResultSetSizeDefinitionMethod>Unlimited</o:ResultSetSizeDefinitionMethod><o:ResultSetSize>2147483647</o:ResultSetSize><o:ResultSetOptimizationCriteria /></o:Parameters><o:CriteriaGroups><o:CriteriaGroup o:operator="And" o:name="Pozitivní" o:loanCaseType="ClassicAccount"><o:Criteria><o:Criterion o:name="KOD_BLOKACE_M_ID"><c:CriterionValue operator="Equal"><c:Primitive><c:Primitive c:type="string">999</c:Primitive></c:Primitive></c:CriterionValue></o:Criterion><o:Criterion o:name="F_AKT_VYSE_MES_SPLATKY"><c:CriterionValue operator="Equal"><c:Primitive><c:Primitive c:type="decimal">6</c:Primitive></c:Primitive></c:CriterionValue></o:Criterion></o:Criteria></o:CriteriaGroup><o:CriteriaGroup o:operator="AndNot" o:name="Negativní" o:loanCaseType="ClassicAccount"><o:Criteria /></o:CriteriaGroup></o:CriteriaGroups></o:MatrixVersionXml

The element <c:Primitive> is generated by the following code

public void WriteXml(XmlWriter writer

writer.WriteStartElement( CriteriaNamespace.PreferredPrefix, "Primitive", CriteriaNamespace.Namespace )
if ( this.Value != null

string type = XmlConvertExt.GetXsiType( this.Value.GetType() )
writer.WriteAttributeString( CriteriaNamespace.PreferredPrefix, "type", CriteriaNamespace.Namespace, type )
writer.WriteString( XmlConvertExt.ToString( this.Value, type ) )


writer.WriteEndElement()


Looks like a bug in the XmlTextWriter, isn't it

Gael Fraiteu

gael dot fraiteur at adastracorp dot com
 
Are you sure that

XmlConvertExt.ToString( this.Value, type )

does not return an empty string?

- Dennis

Gael Fraiteur said:
Hello,

Bug description: calling XmlTextWriter.WriteString with a one-character
long argument could have no effect (nothing is written).
Workaround: use WriteRaw or insert a white space before.

Circumstances: I could not reproduce in a standalone program. In my
complete application, the attached XML should be generated, but instead of
<c:Primitive c:type="decimal">6</c:Primitive>

I get

<c:Primitive c:type="decimal" />.

The complete XML is:

<o:MatrixVersionXml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:c="uri:adastra.criteria"
xmlns:o="uri:cetelem.otis"><o:Parameters><o:Comment /><o:ResponsiblePerson
/><o:SendDate>2004-03-18T10:33:52.1434992+01:00</o:SendDate><o:ControlGroupS
izeDefinitionMethod>Absolute</o:ControlGroupSizeDefinitionMethod><o:ControlG
roupSize>1000</o:ControlGroupSize><o:ResultSetSizeDefinitionMethod>Unlimited
</o:ResultSetSizeDefinitionMethod><o:ResultSetSize>2147483647</o:ResultSetSi
ze><o:ResultSetOptimizationCriteria
/></o:Parameters><o:CriteriaGroups><o:CriteriaGroup o:operator="And"
o:name="Pozitivní"
o:loanCaseType="ClassicAccount"><o:Criteria><o:Criterion
o:name="KOD_BLOKACE_M_ID"><c:CriterionValue
operator="Equal"><c:Primitive><c:Primitive
c:type="string">999</c:Primitive></c:Primitive></c:CriterionValue></o:Criter
ion><o:Criterion o:name="F_AKT_VYSE_MES_SPLATKY"><c:CriterionValue
operator="Equal"><c:Primitive><c:Primitive
c:type="decimal">6</c:Primitive></c:Primitive></c:CriterionValue></o:Criteri
on></o:Criteria></o:CriteriaGroup><o:CriteriaGroup o:operator="AndNot"
o:name="Negativní" o:loanCaseType="ClassicAccount"><o:Criteria
/> said:
The element <c:Primitive> is generated by the following code:

public void WriteXml(XmlWriter writer)
{
writer.WriteStartElement( CriteriaNamespace.PreferredPrefix, "Primitive", CriteriaNamespace.Namespace );
if ( this.Value != null )
{
string type = XmlConvertExt.GetXsiType( this.Value.GetType() );
writer.WriteAttributeString( CriteriaNamespace.PreferredPrefix, "type",
CriteriaNamespace.Namespace, type );
 
Back
Top