DataSource Control + Read XML Data from Stream

D

donmalla

Hello,

I am using OWC 11, On IIS 6.0, Win XP, to render charts, however I am
having trouble connection an XML data stream as the data source.
I will be sending xml data as a request parameter.

I am trying to follow this article,

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q249805

When I give the full harcoded path of data.xml as (c:\\data.xml), it
works fine.
However if I give "http://localhost/data.xml" or just "data.xml",

I get the following error:

############################ ERROR MSG START ##########################

Error Type:
Microsoft Office 2003 Web Components (0x80030002)
Error opening data file "data.xml".
/owc/chart/ASP/ChartXMLDSC.asp, line 51


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322; .NET CLR 2.0.50215)

Page:
GET /owc/chart/ASP/ChartXMLDSC.asp

Time:
Thursday, November 17, 2005, 5:49:51 PM


More information:
Microsoft Support

############################ ERROR MSG END ##########################


Sample Code:

########################## START ASP PAGE ###########################

<%@ Language=VBScript %>
<% Option Explicit %>

<!-- #include file="VBScriptDebug.asp" -->


<%

'Declare your Debug object.
Dim Debug
Dim lstChartType
Dim mydoc
Dim ChartSpace1, c, oChart
Dim sDataPath, nCatID


'Instantiate the Debug object.


'Enable the Debug object. In the future, you can set it to false to
disable it.
'The rest of your debug code can be left in the page.


Dim rootNode
' set rootNode = mydoc.documentElement

Randomize()
'Create an in-memory reference to the Chart component

Set ChartSpace1 = Server.CreateObject("OWC11.ChartSpace")


Dim DSC
Set DSC = CreateObject("OWC11.DataSourceControl")
' Set the DSCs ConnectionString.
' Note Change this line if you move the MDB file or
' want to connect to a different MDB file.


DSC.ConnectionString = "Provider=MSPersist"

' Add a RecordsetDef which will be a
' row source for the Chart control

DSC.RecordsetDefs.AddNew "data.xml", _
DSC.Constants.dscCommandFile, "ChartData"

set c = ChartSpace1.Constants

'Clear the ChartSpace1
ChartSpace1.Clear
ChartSpace1.Border.Color = c.chColorNone

set ChartSpace1.DataSource = DSC
ChartSpace1.DataMember = "ChartData"
ChartSpace1.HasMultipleCharts = False
ChartSpace1.PlotAllAggregates = c.chPlotAggregatesSeries
ChartSpace1.SetData c.chDimCategories, 0, "Values1"
ChartSpace1.SetData c.chDimSeriesNames, 0, "Values2"
ChartSpace1.SetData c.chDimValues, 0, "Values3"

ChartSpace1.DisplayFieldButtons = False

Set oChart = ChartSpace1.Charts.Item(0)
oChart.Type =0 'c.chChartTypeLineMarkers
Dim ax,ay
Set ax = oChart.Axes(c.chAxisPositionBottom)
ax.HasTitle=True
ax.Title.Caption="X Axis"

'ay = oChart.Axes(c.chAxisPositionLeft)
'ay.HasTitle=True
'ay.Title.Caption="Y Axis"

if oChart.SeriesCollection.Count > 1 then
oChart.HasLegend = True
oChart.Legend.Position = c.chLegendPositionBottom
end if


'Use the SessionID and file count to determine a unique filename
Dim sFilename
sFilename = "temp_" & CStr(Rnd()) & ".GIF"

'Create a GIF image of the Chart
ChartSpace1.ExportPicture Server.MapPath(sFilename), "GIF", 700,
700
'Response.ContentType "application/text"
Response.Write sFilename
Response.Flush

Set ChartSpace1 = Nothing
Set mydoc= Nothing
%>


<HTML>
<BODY>
<IMG SRC='<%=sFilename%>'>
</BODY>
</HTML>

#############################END ASP PAGE #########################


############################## data.xml
################################


<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>



<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly'>
<s:attribute type='Values1'/>
<s:attribute type='Values2'/>
<s:attribute type='Values3'/>
<s:extends type='rs:rowbase'/>
</s:ElementType>
<s:AttributeType name='Values1' rs:number='1' rs:nullable="false"
displayname='Machines'>
<s:datatype dt:type='string' dt:maxLength='10'/>
</s:AttributeType>
<s:AttributeType name='Values2' rs:number='3' rs:nullable="true"
displayname='Category'>
<s:datatype dt:type='string' dt:maxLength='10'
rs:precision='5' rs:fixedlength='true' rs:maybenull='false'/>
</s:AttributeType>
<s:AttributeType name='Values3' rs:number='2' displayname='Values'>
<s:datatype dt:type='i2' dt:maxLength='2' rs:precision='5'
rs:fixedlength='true' rs:maybenull='false'/>
</s:AttributeType>

</s:Schema>

<rs:data>
<z:row Values1=' Machine0' Values2='A' Values3='32' />
<z:row Values1=' Machine1' Values2='B' Values3='41' />
<z:row Values1=' Machine2' Values2='A' Values3='27' />
<z:row Values1=' Machine3' Values2='B' Values3='66' />
<z:row Values1=' Machine4' Values2='A' Values3='83' />
<z:row Values1=' Machine5' Values2='B' Values3='80' />
<z:row Values1=' Machine6' Values2='A' Values3='34' />
</rs:data>
</xml>

#################################### data.xml END
#######################


Thanks,
Ratnakar
 
A

Antoine Prevot

Hello,

Hi Ratnakar,
I am using OWC 11, On IIS 6.0, Win XP, to render charts, however I am
having trouble connection an XML data stream as the data source.
I will be sending xml data as a request parameter.

When I give the full harcoded path of data.xml as (c:\\data.xml), it
works fine.
However if I give "http://localhost/data.xml" or just "data.xml",

I get the following error:

I didn't read your source code, but i suppose that IIS won't allow you to
establish his root directory on "C:\", so that "http://localhost/data.xml"
and "C:\\data.xml" won't match.

Did you try to open your dada file with IE ? Do you have permission to
access it or do you get a 404 (.2) error ?

Tonio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top