Help request: IStream implementation for saving objects into XML DOM Documents 
Author Message
 Help request: IStream implementation for saving objects into XML DOM Documents

Let's consider the following VB code working with SQL Server 2000 and ADO2.6

Private Sub Test()
Dim adoCmd As ADODB.Command
Dim xmlDoc As New MSXML2.DOMDocument
Dim stmSQL As String
stmSQL = ..... SQL string with FOR XML EXPLICIT syntax...

Set adoCmd = New ADODB.Command
adoCmd.ActiveConnection = "Provider=SQLOLEDB;Password=;Persist Security
Info=True;User ID=SA;Initial Catalog=Cribis;Data Source=CHARLIEBROWN"
adoCmd.CommandText = stmSQL
adoCmd.CommandType = adCmdText
adoCmd.Properties("Output Stream") = xmlDoc
adoCmd.Execute , , adExecuteStream

after the Execute method I have in xmlDoc the result already parsed in a
DOMDocument!!!

The question is how should I implement IStream in my ATL object to do
something like this in the more efficient way:
Dim objXml as DOMDocument
Dim objMsg as New MyLib.Message
....
obtain the message object
....
' save the Msg in a passed DOM Document using IStream
objMsg.Save(objXml)

I mean is there a way I can avoid working with the DOM in my ATL component
and build the xml using only streams?
HRESULT CMessage::Save(VARIANT *vStream)
{
        suppose I have a CComBSTR which holds an xml text how can i put it
into the passed DOM reference?
        should I parse my string in a DOM docuement here? Where's the magic
to avoid this time consuming process?

Quote:
}

Please any help will be appreciated! I can give more details if needed
Thanks,
Mario


Sat, 24 May 2003 03:00:00 GMT  
 Help request: IStream implementation for saving objects into XML DOM Documents

Well I'm closer to the solution but I'm facing a big problem now.
I derived my ATL class from ISequentialStream and implemented the 2 methods
Read and Write and it wors pretty fine.

When I execute the Load method of a IXMLDOMDocument interface from VB like
this:
Dim objMsg as New MyLib.Message 'my object supporting ISequentialStream
Dim obj As New DOMDocument
obj.load objMsg

the DOMDocument calls the following method implementation requesting 4095
bytes (the value passed in cb)
and if the xml text (kept in a CComBSTR member variable) is less or equal
this value everything goes ok.
BUT if my member variable m_Body holds a 25 KBytes xml string I may expect
my method to be called several times no? This doesn't happen!!!
The DOM Document calls my Read method only 1 time requesting always 4095
bytes and so getting an incomplete xml text which cannot be parsed.
Should I return a different HRESULT to signal there is more data to read? I
tried E_PENDING and S_FALSE but nothing change...
Please Heeeeeeeelp!

STDMETHODIMP CMessage::Read(void *pv, ULONG cb, ULONG *pcbRead)
{
 DWORD cbBody = m_Body.Length()*sizeof(OLECHAR);

 *pcbRead = 0;
 if (m_Index < cbBody)
 {
  *pcbRead = __min(cb, cbBody - m_Index);
  memcpy(pv, m_Body.m_str, *pcbRead);
  m_Index += *pcbRead;
 }

 return S_OK;

Quote:
}



Quote:
> Let's consider the following VB code working with SQL Server 2000 and
ADO2.6

> Private Sub Test()
> Dim adoCmd As ADODB.Command
> Dim xmlDoc As New MSXML2.DOMDocument
> Dim stmSQL As String
> stmSQL = ..... SQL string with FOR XML EXPLICIT syntax...

> Set adoCmd = New ADODB.Command
> adoCmd.ActiveConnection = "Provider=SQLOLEDB;Password=;Persist Security
> Info=True;User ID=SA;Initial Catalog=Cribis;Data Source=CHARLIEBROWN"
> adoCmd.CommandText = stmSQL
> adoCmd.CommandType = adCmdText
> adoCmd.Properties("Output Stream") = xmlDoc
> adoCmd.Execute , , adExecuteStream

> after the Execute method I have in xmlDoc the result already parsed in a
> DOMDocument!!!

> The question is how should I implement IStream in my ATL object to do
> something like this in the more efficient way:
> Dim objXml as DOMDocument
> Dim objMsg as New MyLib.Message
> ....
> obtain the message object
> ....
> ' save the Msg in a passed DOM Document using IStream
> objMsg.Save(objXml)

> I mean is there a way I can avoid working with the DOM in my ATL component
> and build the xml using only streams?
> HRESULT CMessage::Save(VARIANT *vStream)
> {
>         suppose I have a CComBSTR which holds an xml text how can i put it
> into the passed DOM reference?
>         should I parse my string in a DOM docuement here? Where's the
magic
> to avoid this time consuming process?
> }

> Please any help will be appreciated! I can give more details if needed
> Thanks,
> Mario



Sun, 25 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. XML DOM and .NET's XML classes

2. Help: difference of document handling between saving and discarding a document

3. saving objects in XML

4. How do you an XML island as a IXMLDOMxxx object in an HTML document

5. Creating an Object from a XML document.......

6. XML DOM via c#/.net

7. DOM vs XML Namespace

8. XML DOM problem

9. XML DOM

10. XML dom

11. XML DOM Problem

12. XML Dom error

 

 
Powered by phpBB® Forum Software