示例#1
0
	// E4X 13.4.1, page 70
	// this = argv[0] (ignored)
	// arg1 = argv[1]
	// argN = argv[argc]
	Atom XMLClass::call(int argc, Atom* argv)
	{
		if ((!argc) || AvmCore::isNullOrUndefined(argv[1]))
		{
			return ToXML (core()->kEmptyString->atom());
		}

		return ToXML(argv[1]);
    }
void ConfigurationManager::WriteXML(const std::string& fileName)
{
   dtCore::RefPtr<dtUtil::XercesWriter> writer = new dtUtil::XercesWriter();
   writer->CreateDocument("STAGEConfig");

   XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* doc = writer->GetDocument();

   ToXML(*doc);

   writer->WriteFile(fileName);
}
示例#3
0
	// E4X 13.4.2, page 70
	// this = argv[0] (ignored)
	// arg1 = argv[1]
	// argN = argv[argc]
	Atom XMLClass::construct(int argc, Atom* argv)
	{
		// We are no longer supporting this weird Rhino behavior.  According to the spec
		// and a discussion with the E4X developers, Rhino is buggy and a no argument
		// constructor should be equivalent to the empty string constructor.
		// !!@ This is different then the spec but runtime behavior of Rhino shows
		// that a "new XML()" call creates some sort of special node that can change 
		// type automatically.
		//var x = new XML();
		//print(x); // prints nothing
		//print(x.nodeKind()); // prints text
		//print(x.children()); // prints nothing
		//x.foo = 5;
		//print(x); // prints 5
		//print(x.nodeKind()); // prints element - how did it switch?
		//print(x.attributes()); // prints nothing
		//print(x.children()); // prints 5

		AvmCore* core = this->core();

		if (!argc || AvmCore::isNullOrUndefined(argv[1]))
		{
			return ToXML (core->kEmptyString->atom());
		}
	
		//XSWFPlayer::m_pInstance->Trace(XString16("XML"));

		Atom x = ToXML (argv[1]);

		

		// if args[0] is xml, xmllist or w3c xml, return a deep copy
		if (AvmCore::isXML(argv[1]) || AvmCore::isXMLList(argv[1]))
		{
			// return deepCopy of x
			XMLObject *x2 = AvmCore::atomToXMLObject(x);
			return x2->_deepCopy()->atom();
		}

		return x;
	}
示例#4
0
bool BXObject::DumpToFile(const std::string &strPath)
{
	std::string strXML = ToXML();
	FILE *fOut = fopen(strPath.c_str(), "w");
	if (!fOut)
		return false;
    
	int nSize = strXML.size();
	int nOut = fwrite(strXML.c_str(), nSize, 1, fOut);

	if (nOut != 1)
	{
		fclose(fOut);
		return false;
	}

	fclose(fOut);
	return true;
}
示例#5
0
const wchar_t *GException::ToXMLUnicode(const char *pzExceptionParent)
{
	ToXML(pzExceptionParent);
	return _ret.Unicode();
}
示例#6
0
void CChangeSet::GetXML(XMLstring& s)
{
	XmlEncoder enc;
	ToXML(enc);
	enc.FinishDocument(s);
}
const char *MyExistingObjectB::WriteDataFormat(GString *pstrDest)
{
	ToXML(pstrDest);  // it cant get much easier than this.
	return *pstrDest;
}
//----------------------------------------------------------------------------
CString CDigitalTraineeStudioDoc::ToXML(){
//----------------------------------------------------------------------------
	PROC_TRACE;

   return ToXML("","");
}
const char *XMLProcedureCall::Execute( XMLObject *pDestinatonObject /*= 0*/, 
							    bool bDestinationObjectTagPresent /* = 1*/)
{
	if (!m_DataSource)
	{
		throw GException("XMLProcedureCall", 8);
	}

	if (!m_strSchema.IsEmpty())
		AddAttribute( "Schema", (const char *)m_strSchema );

	m_DataSource->AddAttributes(this);
	if ( m_lstProcedures.Size() > 1  ||		// Multiple DB operations or joins(within the same transaction) 
		 m_bForceTransaction 		 ||		// Force Transactional
		 strstr((const char *)m_strProcedureName,"::") )	// executing CustomDLL.procedure

	{
		AddAttribute( "Transaction", "yes" );
	}

	if ( GetRowCount() != (long)-1 )
	{
		AddAttribute( "maxObjects", GetRowCount() );
	}

	if (m_pzReportTemplateName)
	{
		AddAttribute( "MergeXML", "yes" );
		AddAttribute( "Template", m_pzReportTemplateName );
	}
	
	ToXML(&m_strRequest);

	if (m_lpfnSend)
	{
		m_lpfnSend((const char *)m_strRequest);
	}

	const char *pDebugFile = GetProfile().GetString("Debug", "DebugTraceXML", false);
	if (pDebugFile && pDebugFile[0])
	{
		// trace out the xml being sent to the server
		GString strTrace;
		strTrace.Format("\n\n\n\nSent To [%s]-----------\n%s",m_DataSource->GetServerAddress(),(const char *)m_strRequest);
		strTrace.ToFileAppend(pDebugFile);
	}
	
	int nRetryCount = 0;
RESEND:
	try
	{
		
		m_strXml = m_DataSource->send(	(const char *)m_strProcedureName,
										(const char *)m_strRequest,
										(int)m_strRequest.Length(),/* Length w/o Null terminator */
										0, 
										&m_pUserData,"TransactXML=");

		if (m_lpfnRecv)
			m_lpfnRecv(m_strXml);

	}
	catch(GException &e)
	{
		// "General error parsing XML stream" means the data was corrupted in transit.
		if (e.GetError() == 7)
		{
			// Resend the request.
			if (nRetryCount++ < 3)
			{
				TRACE_WARNING("Attempting resend" );
				goto RESEND;
			}
		}
		
		// "the handle is invalid".  We need to 'reboot' the datasource. (WININET)
		if ((e.GetError()  == 6) && 
			(e.GetSystem() == 0)) 
		{
			// Resend the request.
			if (nRetryCount++ < 3)
			{
				TRACE_WARNING("Attempting resend" );
				m_DataSource->IPAddressChange();
				goto RESEND;
			}
		}

		// This helps distinguish Client errors from Server errors
		// unless the error was a client side connect error.
		throw GException("XMLProcedureCall", 4, m_DataSource->GetServerAddress(), e.GetDescription());
	}

	if (pDebugFile && pDebugFile[0])
	{
		// trace out the xml returned from the server
		GString strTrace("\n\n\n\nReceived:\n----------\n");
		const char *pXML = GetXML();
		if (pXML)
			strTrace += pXML;
		strTrace.ToFileAppend(pDebugFile);
	}

	// map to tags that we expect to recieve in the query results
	LoadMemberMappings();

	if ( m_bRunObjectFactory && m_strXml && m_strXml[0] )
	{
		const char *pFactoryXML = m_strXml;
		if (m_pzReportTemplateName)
		{
			pFactoryXML = GetXML();
		}
		
		try
		{
			if (pDestinatonObject)
			{
		
				// The tag "XMLQueryResults" can be anything.  The outer most
				// tag is never verified, this object will contain the Root
				// starting point for factorization (the pDestinatonObject object)
				if (bDestinationObjectTagPresent)
				{
					XMLRelationshipWrapper objectContainer("XMLQueryResults");

					objectContainer.ModifyObjectBehavior(PREVENT_AUTO_DESTRUCTION);


					const char *tag = pDestinatonObject->GetObjectTag();
					objectContainer.AddReference(	tag, pDestinatonObject );


					// When we are paring into an object and the object tag is
					// specified in the XML.  For example, when placing:
					// <Results>
					//		<Customer>
					//			<Widgit>
					//				...
					//			</Widgit>
					//		</Customer>
					// </Results>

					// This will allow us to put Widgit's in a 'Customer' or any 
					// type of object that the pDestinatonObject describes.
					objectContainer.FromXML(pFactoryXML,this);
				}
				else
				{
					// When we are paring into an object but that object is not
					// specified in the XML.  For example, when placing:
					// <Results>
					//		<Widgit>
					//			...
					//		</Widgit>
					// </Results>

					// This will allow us to put Widgit's in a 'Customer' or any 
					// type of object that the pDestinatonObject describes.
					pDestinatonObject->FromXML(pFactoryXML,this);
				}
			}
			else
			{
				XMLObjectFactory factory ( pFactoryXML,m_DataSource->GetServerAddress() );
				// Only Queries have result descriptors
				if ( getResultObjectTag() )
				{
					factory.setResultDescriptor( GetEntry( getResultObjectTag() ) );
				}
				factory.extractObjects(this);
			}
		}
		catch (GException &)
		{
			throw;
		}

// in a debug build, this code is better off compiled out so that the debugger will break closer to the problem.
// in a release build, this may help to 'crash softer'.
#ifndef _DEBUG
		// if we should catch an unhandled exception here
		catch ( ... )
		{
			TRACE_ERROR("Fatal Error while factory creating objects" );
			TRACE_ERROR("1. Check your String/List Handlers" );
			TRACE_ERROR("2. Did you delete a cached object and not remove it from the cache?");
	
			throw GException("XMLProcedureCall", 6);
		}
#endif

	}
	else
	{
		if (m_bRunObjectFactory)
		{
			// we should never get nothing, it may indicate 
			// communication failure depending on the type of DataSource
			TRACE_WARNING("Nothing received from DataBroker" );
			throw GException("XMLProcedureCall", 7);
		}
	}
	return m_strXml;
}