domParser.Process throws Dom parser operation failed in lotus script - lotus-domino

I need to read xml file from local disk using lotus script.
I added the code in the script library and called from the notes view.
origXML = "d:\dxl\xmldom.xml"
outputFile = "d:\dxl\DOMtree.txt"
On Error Goto errh
Set session = New NotesSession
Set db = session.CurrentDatabase
'create the output file
Set outputStream =session.CreateStream
outputStream.Open (outputFile)
outputStream.Truncate
Set inputStream = session.CreateStream
inputStream.Open (origXML)
'create DOM parser and process
Set domParser=session.CreateDOMParser(inputStream, outputStream)
domParser.Process
output and input stream , all are getting. But It throws the following error in domParser.Process
Dom parser operation failed
Please help me to solve this.
Any help would be appreciated.

I have the same error. See detail in domParser.log. Maybe incorrect encoding type or not found xsd|xslt stylesheet by url.

I ran into the same issue. Instead of just removing the XML header attributes you can do something like the following. InputValidationOption property
'create DOM parser and process
Set domParser = session.CreateDOMParser(inputStream, outputStream)
domParser.InputValidationOption = VALIDATE_NEVER
domParser.Process

Taken from the Designer Help:
Note In Release 7.0, this method was enhanced to handle a DTD located at a URL. However, when using a URL, DOMParser.Process() will intermittently fail raising error #4602:"DOM parser operation failed" if the load on the server is too heavy, resulting in a time-out. If this occurs, the calling application will need to try again.
So it is likely a problem with the dtd, either dtd server isn't responding or responding to slow. I had the same problem and solved it by just trying again if process failed. See code below:
Public Sub ParseString(s As String)
On Error 4602 GoTo ParserOperationFailed
Const MAX_RETRIES = 10
Dim isProcessed As Boolean
Dim numOfRetries As Integer
Set domParser = session.Createdomparser(s)
Do While numOfRetries < MAX_RETRIES And isProcessed = False
Call domParser.Process()
isProcessed = true
Retry:
Loop
If Not isProcessed Then
Error 1000, "Unable to get dtd, DOM parser operation failed, tried " + CStr(numOfRetries+1) + "times"
End If
Set xmlDoc = domParser.Document
Set Me.m_rootNode = xmlDoc.Documentelement
Exit Sub
ParserOperationFailed:
isProcessed = False
numOfRetries = numOfRetries + 1
Resume Retry
End Sub

The problem is in the xml header. It was
<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">
I removed all the attributes. I changed to <xml>, and it works.

Related

Setting AutoCAD ActiveSpace to ModelSpace VB.NET

I am trying to ensure that I am addressing entities in ModelSpace, but I get an exception that gives no hint at what the problem is because it's a COM object I guess. Does anyone know what I might be doing wrong? If I take out that line (and the zoom extents line) the remaining code works just fine, so I know my document object is being set correctly.
Dim acDWG As AutoCAD.AcadDocument
' open the drawing
acDWG = acApp.Documents.Open(dgvr.Cells("FullName").Value.ToString)
' ensure the drawing has the modelspace tab activated (doesnt work)
acDWG.ActiveSpace = AutoCAD.AcActiveSpace.acModelSpace
' zoom to extents (sometimes works, sometimes not) '
acApp.ZoomExtents()
' build a selectionset of all blocks named 'Solid1' and then delete them all
Dim ss As AutoCAD.AcadSelectionSet = acDWG.SelectionSets.Add("DELETE")
Dim gpCode(1) As Int16
Dim dataValue(1) As Object
gpCode(0) = 0 : dataValue(0) = "Insert"
gpCode(1) = 2 : dataValue(1) = "Solid1"
ss.Select(AutoCAD.AcSelect.acSelectionSetAll,,, gpCode, dataValue)
ss.Erase()
ss.Delete()
ss = Nothing
Update: I discovered why I am getting the error. The code is correct, but the problem is that the drawing has not completed opening yet. If I put a "wait for 5 seconds" line of code directly after the Open line, it works just fine. So it seems my question is how to open the drawing and have VB.Net wait for a signal from the COM object that it is "ready to continue"? (not sure how to word it)
Use a combination of Do...Loop and a Try...Catch block to "wait" like this:
Dim acDWG As AutoCAD.AcadDocument
acDWG = acApp.Documents.Open(dgvr.Cells("FullName").Value.ToString)
Dim bOpen As Boolean = False
Do Until bOpen = True
Try
acDWG.ActiveSpace = AutoCAD.AcActiveSpace.acModelSpace
bOpen = True
Catch ex As Exception
' ignore the error and try again until it is open
End Try
Loop

mshtml.IHTMLDocument returning nothing

I have the below code trying to access a webpage and the program is erroring out at a test for the innerHTML property. Below is the code:
iex = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
iex.visible = True
iex.navigate("https://url.aspx")
While iex.readystate <> 4 Or iex.busy
Application.DoEvents()
End While
Dim htdoc As mshtml.IHTMLDocument = iex.Document
Dim htstring As mshtml.IHTMLBodyElement = htdoc.body
If (InStr(htstring.innerHTML, "An error occured while processing your request") > 0) Then
The last line is where it gets the error. And I have determined that it gets the error because htdoc is nothing, resulting in everything else being nothing. At least, that is what I believe the issue to be.
After further troubleshooting, the below line is what is causing the error.
mshtml.IHTMLBodyElement = htdoc.body
The exception error is:
Message = Exception from HRESULT: 0x800A01B6
Item = In order to evaluate an indexed
property, the property must be qualified and the arguments must be
explicitly supplied by the user.
This was working before IE was updated to IE11 (I don't recall what version it was prior, but I would assume it was IE10).
I don't think I am doing anything wrong, but any help you could provide would be greatly beneficial!

could not find a part of the path

I have a XSD file which i am using to validate XML. The problem is i get an error. The error is not thrown when i run the code in local machine. But if i run the code in integration, the error is thrown.
Dim strSchemaPath As String = String.Empty
Dim xmlSettings As XmlReaderSettings = Nothing
Dim msStream As MemoryStream = Nothing
IsXMLValid = True
msStream = New MemoryStream(System.Text.ASCIIEncoding.UTF8.GetBytes(xmlRequest))
strSchemaPath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "XSD\Input.xsd")
xmlSettings = New XmlReaderSettings()
xmlSettings.ValidationType = ValidationType.Schema
xmlSettings.Schemas.Add(Nothing, strSchemaPath)
There was no issues with access of the file. There was a issue with the files to be copied in the server path. We can manage the files in the properties. I just changed the file property to copy always and it worked.

while trying to read a particular text from notepad am facing Run Error :- Object doesnt support this property or method

set objFileToRead = CreatObject("Scripting.FileSystemObject")
Set strReadline=objFileToRead.OpenTextFile(strpath,1)
Do While strReadline.AtEndofStream<>True
strRecordName = Trim(Mid(strReadLine,52,15)
AT 4th LINE FACING ERROR in hp-UFT Run Error :- Object doesn't support this property or method
Please paste the code without syntax error .Your code should be like this
strpath="C:\Users\561320\Documents\Saikrishna\caffeine\readme.txt"
set objFileToRead = CreateObject("Scripting.FileSystemObject")
Set strReadline=objFileToRead.OpenTextFile(strpath,1)
Do While strReadline.AtEndofStream<>True
strRecordName = Trim(Mid(strReadLine.Readline,52,15))
Wscript.echo strRecordName
Loop

VB:NET "Object reference not set to an instance of an object." in a Net.WebResponse variable

in the following code i am trying to handle different server resposes:
this function is used to read xml or html soruce from a web page
and in the commented line i get "Object reference not set to an instance of an object."
i wonder why.
Public Function GetPageHTML(ByVal URL As String, _
Optional ByVal TimeoutSeconds As Integer = 10) _
As String
' Retrieves the HTML from the specified URL,
' using a default timeout of 10 seconds
Dim objRequest As Net.WebRequest
Dim objResponse As Net.WebResponse
Dim objStreamReceive As System.IO.Stream
Dim objEncoding As System.Text.Encoding
Dim objStreamRead As System.IO.StreamReader
Try
' Setup our Web request
objRequest = Net.WebRequest.Create(URL)
objRequest.Timeout = TimeoutSeconds * 1000
' Retrieve data from request
Select Case CType(objResponse, Net.HttpWebResponse).StatusCode 'Here is where i get the error Object reference not set to an instance of an object.
Case Net.HttpStatusCode.InternalServerError
'This is sloppy, but a quick example for one of your sub-questions.
System.Threading.Thread.Sleep(10000)
'Try again.
objResponse = objRequest.GetResponse
Case Net.HttpStatusCode.BadRequest
'Error Handling
Case Net.HttpStatusCode.OK
'Proceed as normal.
Case Else
'Error Handling
End Select
objStreamReceive = objResponse.GetResponseStream
objEncoding = System.Text.Encoding.GetEncoding( _
"utf-8")
objStreamRead = New System.IO.StreamReader( _
objStreamReceive, objEncoding)
' Set function return value
GetPageHTML = objStreamRead.ReadToEnd()
' Check if available, then close response
If Not objResponse Is Nothing Then
objResponse.Close()
End If
Catch
' Error occured grabbing data, simply return nothing
Return ""
End Try
End Function
now when i remove the switch statement and just write the objResponse as
objResponse = objRequest.GetResponse
except i get an exception of error 403 or 503, i don't know how to handle this.
Your error line:
Select Case CType(objResponse, Net.HttpWebResponse).StatusCode
is called without ever assigning anything to objResponse.
You need to change it to:
objResponse = objRequest.GetResponse
Select Case CType(objResponse, Net.HttpWebResponse).StatusCode`
In regards to getting HTTP error codes for the page you are trying to ftech, here are the meanings of them and their causes:
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
First off, tcarvin is correct, your question's code is missing this line:
objResponse = objRequest.GetResponse
Secondly, you can do this to resolve your other issue:
If Not objResponse Is Nothing Then
'Select Case Code
Else
'Handle failure.
End If