[xsd-users] Fwd: XSD cd-Tree - LandXML Wrong Serializing
Constantin Iacobescu
sir.costy at gmail.com
Mon Mar 2 04:37:44 EST 2009
Hi,
I think i found where I have wrong. I supposed that the NamespaceInfomap is
also saved and you don't have to create it again.
So the working code shold be this.
xml_schema::NamespaceInfomap infoMap;
infoMap[""].name = "http://www.landxml.org/schema/LandXML-1.2";
infoMap[""].schema = "
http://www.landxml.org/schema/LandXML-1.2/LandXML-1.2.xsd";
serializeLandXML (ofs,
*objLandXML,
infoMap );
Regards
Costy
---------- Forwarded message ----------
From: Constantin Iacobescu <sir.costy at gmail.com>
Date: Mon, Mar 2, 2009 at 9:55 AM
Subject: XSD cd-Tree - LandXML Wrong Serializing
To: xsd-users at codesynthesis.com
Hello,
I had tried to parse and serialize an xml file which use the LandXML.xsd
specifications. So the binding command was some like:
xsd cxx-tree --generate-serialization --generate-polymorphic
--generate-doxygen --generate-wildcard --generate-ostream --type-naming java
--function-naming java --namespace-map
http://www.landxml.org/schema/LandXML-1.2=NSXML LandXML-1.2.xsd
The input xml fil start like this:
<?xml version="1.0"?>
<LandXML xmlns="http://www.landxml.org/schema/LandXML-1.2" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.landxml.org/schema/LandXML-1.2
http://www.landxml.org/schema/LandXML-1.2/LandXML-1.2.xsd" version="1.2"
date="2003-10-01" time="13:16:41" readOnly="false" language="English">
<Project name="mantopo" desc="mantopo"/>
<Units>
<Imperial linearUnit="USSurveyFoot" areaUnit="squareFoot"
volumeUnit="cubicFeet" temperatureUnit="fahrenheit" pressureUnit="inHG"/>
</Units>
</LandXML>
But now is coming the bad think because the serialized file looks some
different. Always has this "p1:" thing which I think is related with some
namespace trouble.
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<p1:LandXML xmlns:p1="http://www.landxml.org/schema/LandXML-1.2"
date="2003-10-01" language="English" readOnly="false" time="13:16:41"
version="1.2">
<p1:Units>
<p1:Imperial angularUnit="radians" areaUnit="squareFoot"
directionUnit="radians" elevationUnit="meter" latLongAngularUnit="decimal
degrees" linearUnit="USSurveyFoot" pressureUnit="inHG"
temperatureUnit="fahrenheit" volumeUnit="cubicFeet"/>
</p1:Units>
<p1:Project desc="mantopo" name="mantopo"/>
</LandXML>
The code use to made that is very simple, just loading and parsing the xml
file and then serializing it
using namespace xercesc;
XMLPlatformUtils::Initialize ();
try
{
using namespace NSXML;
namespace xml = xsd::cxx::xml;
namespace tree = xsd::cxx::tree;
std::auto_ptr<LandXML> objLandXML ( parseLandXML("InXML.xml",
xml_schema::Flags::dont_initialize));
// and now serialize it
std::ofstream ofs;
ofs.open ("OutXML.xml");
serializeLandXML (ofs, *objLandXML)
}
Some simple thing but I don´t understand what´s going wrong by here that is
generated that "p1" thing.
Please help me.
Regards,
Constantin Iacobescu
--
Constantin Iacobescu
More information about the xsd-users
mailing list