|
-
Problem accessing the XML from the server
I have a measurement converter that is xml based.
Basically, I have an HTML with VB and Java scripts that talks to an xml file
that contains all the metrics name and units.
Somehow, my program works fine when I open it from my local drive.
But when I try and open it on the server like:
http://wwc1/Converter/conversion.html
It will not populate the information from the xml file.
All is shown is empty text boxs.
That is how I call my xml file(here also a segment of my code):
<script language="vbscript">
' Global variables
XML_FILE_PATH = "conversion.xml"
dim xObj
XMLLoaded = false
XMLTree = 0
function Go()
' Start running a conversion
' Grab all form values
DataGroupString = document.conversionform.unitgroup.value
DataFromString = document.conversionform.fromname.value
DataToString = document.conversionform.toname.value
DataAmountString = document.conversionform.amount.value
' Use Default value of 1
if Trim(DataAmountString) = "" then DataAmountstring = 1
' Run conversion and set results boxes
document.conversionform.left.value = DataAmountString & " " & DataFromString
document.conversionform.right.value = DoConversion(DataGroupString,
DataAmountString, DataFromString, DataToString) &
" " & DataToString
end function
function ChangeGroup()
' Clears and repopulates "to" and "from" boxes based on unitgroup change
DataGroupString = document.conversionform.unitgroup.value
ClearBox()
UnitSet = GetUnitList(DataGroupString)
for J = 0 to UBound(UnitSet)
AddToBox UnitSet(J), DataGroupString
next
end function
function LoadBaseGroup()
' This is run only once and populates the unit group box
GroupSet = GetUnitGroupList()
for I = 0 to UBound(GroupSet)
AddToTopBox(GroupSet(I))
next
ChangeGroup()
end function
function DoConversion(UnitGroup, Value, FromString, ToString)
' This function actually runs the conversion
if not XMLLoaded then
' Don't re-parse the xml if not needed
set XMLTree = CreateObject("Microsoft.xmldom")
XMLTree.load(XML_FILE_PATH)
XMLLoaded = true
end if
' At this point the xml file has been loaded
HaveFrom = false
HaveTo = false
' Control variables
set CategorySet = XMLTree.documentElement.selectNodes("//unitgroup")
for Each Category in CategorySet
' Check each unitgroup for the current one
for each Attribute in Category.attributes
if Attribute.nodeName = "name" and trim(lcase(Attribute.nodeValue))
= trim(lcase(Unitgroup)) then
' Found the correct unitgroup
set UnitSet = Category.selectNodes("unit")
for each Unit in UnitSet
' Check each unit for the "from" and "to" units
for each SubAttribute in Unit.attributes
if SubAttribute.nodeName = "name" and trim(lcase(SubAttribute.nodeValue))
= trim(lcase(FromString)) then
' Found "From"
set FromTag = Unit
HaveFrom = true
end if
if SubAttribute.nodeName = "name" and trim(lcase(SubAttribute.nodeValue))
= trim(lcase(ToString)) then
' Found "To"
set ToTag = Unit
HaveTo = true
end if
next
next
end if
next
next
if HaveFrom and HaveTo then
' Both were found
Scale = 1
Offset = 0
for each Attribute in FromTag.attributes
' Conversion to the base unit
if Attribute.nodeName = "scaleN" then
Scale = Scale / Attribute.nodeValue
elseif Attribute.nodeName = "scaleD" then
Scale = Scale * Attribute.nodeValue
elseif Attribute.nodeName = "offset" then
Offset = Offset + Attribute.nodeValue
end if
next
NewValue = Scale * (Value - Offset)
Scale = 1
Offset = 0
for each Attribute in ToTag.attributes
' Conversion from the base unit to this one
if Attribute.nodeName = "scaleN" then
Scale = Scale * Attribute.nodeValue
elseif Attribute.nodeName = "scaleD" then
Scale = Scale / Attribute.nodeValue
elseif Attribute.nodeName = "offset" then
Offset = Offset + Attribute.nodeValue
end if
next
NewValue = Scale * NewValue + Offset
DoConversion = NewValue
else
' Oops, unit not found
DoConversion = "[Error]"
end if
end function
PLEASE ADVISE.
Thank you,
Amr
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks