#endif
LDOM_XmlReader::RecordType ReadRecord (LDOM_XmlReader& aReader,
Standard_IStream& theIStream,
- LDOM_OSStream& aData)
+ LDOM_OSStream& aData,
+ Standard_Boolean& theDocStart)
{
#ifdef LDOM_PARSER_TRACE
static aCounter = 0;
++ aCounter;
#endif
- const LDOM_XmlReader::RecordType aType = aReader.ReadRecord (theIStream, aData);
+ const LDOM_XmlReader::RecordType aType = aReader.ReadRecord (theIStream, aData, theDocStart);
#ifdef LDOM_PARSER_TRACE
static FILE * ff = NULL;
TCollection_AsciiString aTraceFileName;
Standard_Boolean isDoctype = Standard_False;
Standard_Boolean isInsertFictRootElement = Standard_False;
+ Standard_Boolean aDocStart = Standard_True;
+
for(;;) {
LDOM_XmlReader::RecordType aType = (theWithoutRoot && !isInsertFictRootElement ?
LDOM_XmlReader::XML_START_ELEMENT :
- ReadRecord (*myReader, theIStream, myCurrentData));
+ ReadRecord (*myReader, theIStream, myCurrentData, aDocStart));
switch (aType) {
case LDOM_XmlReader::XML_HEADER:
if (isDoctype || isElement) {
myError = "User abort at startElement()";
break;
}
- isError = ParseElement (theIStream);
+ isError = ParseElement (theIStream, aDocStart);
if (isError) break;
continue;
}
//purpose : parse one element, given the type of its XML presentation
//=======================================================================
-Standard_Boolean LDOMParser::ParseElement (Standard_IStream& theIStream)
+Standard_Boolean LDOMParser::ParseElement (Standard_IStream& theIStream, Standard_Boolean& theDocStart)
{
Standard_Boolean isError = Standard_False;
const LDOM_BasicElement * aParent = &myReader->GetElement();
LDOM_Node::NodeType aLocType;
LDOMBasicString aTextValue;
char *aTextStr;
- LDOM_XmlReader::RecordType aType = ReadRecord (* myReader, theIStream, myCurrentData);
+ LDOM_XmlReader::RecordType aType = ReadRecord (* myReader, theIStream, myCurrentData, theDocStart);
switch (aType) {
case LDOM_XmlReader::XML_UNKNOWN:
isError = Standard_True;
myError = "User abort at startElement()";
break;
}
- isError = ParseElement (theIStream);
+ isError = ParseElement (theIStream, theDocStart);
break;
case LDOM_XmlReader::XML_END_ELEMENT:
{
//=======================================================================
LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStream,
- LDOM_OSStream& theData)
+ LDOM_OSStream& theData,
+ Standard_Boolean& theDocStart)
{
theData.Clear();
myError.Clear();
LDOMBasicString anAttrName, anAttrValue;
char anAttDelimiter = '\0';
Standard_Boolean aHasRead = Standard_False;
- Standard_Boolean isFileStart = !myEOF && theIStream.tellg() == std::iostream::pos_type(0);
for(;;) {
// Check if the current file buffer is exhausted
myBuffer[aBytesRest + aNBytes] = '\0';
}
}
- if (isFileStart)
+ if (theDocStart && !myEOF)
{
- isFileStart = Standard_False;
+ theDocStart = Standard_False;
// check for BOM block
Standard_Utf8UChar aFirstChar = Standard_Utf8UChar(myPtr[0]);
switch(aFirstChar) {
// Constructor - takes a file descriptor for input
// Constructor - takes an std::istream for input
- RecordType ReadRecord (Standard_IStream& theIStream, LDOM_OSStream& theData);
+ RecordType ReadRecord (Standard_IStream& theIStream,
+ LDOM_OSStream& theData,
+ Standard_Boolean& theDocStart);
// reading a markup or other element of XML format
- LDOM_BasicElement& GetElement () const { return * myElement; }
+ LDOM_BasicElement& GetElement() const { return * myElement; }
// get the last element retrieved from the stream
void CreateElement (const char *theName, const Standard_Integer theLen);
- static Standard_Boolean getInteger (LDOMBasicString& theValue,
- const char * theStart,
- const char * theEnd);
+ static Standard_Boolean getInteger (LDOMBasicString& theValue,
+ const char * theStart,
+ const char * theEnd);
// try convert string theStart to LDOM_AsciiInteger, return False on success
// Returns the byte order mask defined at the start of a stream