个人猜测domino-webservice引用%INCLUDE "lsxsd.lss" 为了补充lotusscript语音和其他开发语言的差距,所以需要补充代码库。
在使用引用追加新的类库。
lsxsd.lss在domino-notes开发环境下可以找到,内容如。其中一些追加新的类。
(感谢QQ群友解惑)
%INCLUDE "lserr.lss"
'--------------------------------------------------------------------
'--------------------------------------------------------------------
' USEFUL DATA CONVERSIONS USED BY ONE OR MORE XML SCHEMA DATATYPES
'--------------------------------------------------------------------
'--------------------------------------------------------------------
CLASS XSD_DATATYPE_CONVERTER
' Convert bytes in a NotesStream into a base64 string
Function notesStreamToBase64 (ns As NotesStream) As String
Const b64Chars$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim nsLength As Long
nsLength = ns.Bytes
ns.Position = 0
Dim numPads As Integer
numPads = (3 - (nsLength Mod 3)) Mod 3
While nsLength > 0
' Output lines are limited to 76 chars, and because every
' three input bytes produce 4 output chars we process
' up to 57 input bytes at a time. (57 = 76 / 4 * 3)
Dim inLength As Long
inLength = nsLength
If inLength > 57 Then inLength = 57
nsLength = nsLength - inLength
Dim outString As String
outString = ""
Dim idx As Integer
idx = 0
While idx < inLength
' Collect up to 24 bits (3 bytes) of input data
Dim outBits As Integer
outBits = 0
Dim bits24 As Long
bits24 = 0
Dim i As Integer
For i = 0 To 2
bits24 = bits24 * 256
If idx + i < inLength Then
Dim buf As Variant
buf = ns.Read(1&)
bits24 = bits24 + buf(0)
outBits = outBits + 8
End If
Next
idx = idx + 3
Dim numChars As Integer
numChars = 4
If outBits <> 24 Then
numChars = 4 - numPads
End If
For i = 1 To numChars
Dim bits6 As Integer
bits6 = (bits24 And &HFC0000&) / 262144
outString = outString & Mid$(b64Chars, bits6 + 1, 1)
bits24 = (bits24 And &H3FFFF&) * 64
Next
If numChars <> 4 Then
For i = 1 To numPads
outString = outString & "="
Next
End If
Wend
' Add another line of base64 output to the return string
notesStreamToBase64 = notesStreamToBase64 & outString & Chr$(13) & Chr$(10)
Wend
End Function
' Convert bytes in a NotesStream into a base64 string
Function notesStreamToBase64Ext (ns As NotesStream) As String
On Error GoTo Fallback
notesStreamToBase64Ext = ns.ReadEncoded(ENC_BASE64, 76) 'internal use only
Exit Function
Fallback:
On Error GoTo ExitFunction
notesStreamToBase64Ext = Me.notesStreamtoBase64(ns)
Exit Function
ExitFunction:
notesStreamToBase64Ext = ""
End Function
' Convert a base64 string into bytes in a NotesStream
Function base64ToNotesStream (b64String As String) As NotesStream
Dim session As New NotesSession
Dim ns As NotesStream
Set ns = session.CreateStream
' variables used to stage output to the NotesStream
Redim buf (0 To 2) As Byte
Dim numPads As Integer
numPads = 0
Dim b64Len As Long
b64Len = Len(b64String)
Dim idx As Long
idx = 1
While idx <= b64Len
Dim currChar As String
currChar = Mid$(b64String, idx, 1)
' Ignore whitespace (CR, LF, SPACE, or TAB) that may lead the line
Dim c As Long
c = Asc(currChar)
If c = 13 Or c = 10 Or c = 32 Or c = 9 Then
idx = idx + 1
Goto Next1
End If
' Every 4 base64 characters represent 24 bits (three 8-bit bytes)
Dim bits24 As Long
bits24 = 0
Dim i As Integer
For i = 0 To 3
Dim bits6 As Long
c = Asc(Mid$(b64String, idx, 1))
idx = idx + 1
' Map characters "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
' to 6-bit binary values ranging from 0 to 63, respectively
Select Case c
Case Asc("A") To Asc("Z")
bits6 = c - Asc("A") ' map A-Z to 0-25
Case Asc("a") To Asc("z")
bits6 = 26 + c - Asc("a") ' map a-z to 26-51
Case Asc("0") To Asc("9")
bits6 = 52 + c - Asc("0") ' map 0-9 to 52-61
Case Asc("+")
bits6 = 62 ' map "+" to 62
Case Asc("/")
bits6 = 63 ' map "/" to 63
Case Asc("=") ' pad char at end of base64
bits6 = 0
numPads = numPads + 1
Case Else
Error ErrOverflow
End Select
bits24 = (bits24 * 64) + bits6
Next
' Extract three 8-bit bytes from the 24-bit value
buf(0) = (bits24 And &HFF0000&) / 65536
buf(1) = (bits24 And &H00FF00&) / 256
buf(2) = bits24 And &H0000FF&
' Write up to three 8-bit bytes to the NotesStream
Select Case numPads
Case 0
Call ns.Write (buf)
Case 1
Redim Preserve buf (0 To 1)
Call ns.Write (buf)
Goto done
Case 2
Redim Preserve buf (0 To 0)
Call ns.Write (buf)
Goto done
End Select
next1:
Wend
done:
Set base64ToNotesStream = ns
End Function
' Convert a base64 string into bytes in a NotesStream
Function base64ToNotesStreamExt (b64String As String) As NotesStream
Dim session As New NotesSession
Dim ns As NotesStream
Set ns = session.CreateStream
On Error GoTo Fallback
Call ns.WriteDecoded(b64String,ENC_BASE64) 'internal use only
Set base64ToNotesStreamExt = ns
Exit Function
Fallback:
On Error GoTo ExitFunction
Set base64ToNotesStreamExt = Me.base64ToNotesStream(b64String)
Exit Function
ExitFunction:
Set base64ToNotesStreamExt = session.CreateStream
End Function
' Convert bytes in a NotesStream into a hexBinary string
Function notesStreamToHexBinary (ns As NotesStream) As String
Const hexChars$ = "0123456789ABCDEF"
Dim nsLength As Long
nsLength = ns.Bytes
ns.Position = 0
While nsLength > 0
' We arbitrarily limit output lines to 76 hex chars
' by inserting CRLF after processing a run of 38
' bytes. (Note: whitespace is allowed in hexBinary).
Dim inLength As Long
inLength = nsLength
If inLength > 38 Then inLength = 38
nsLength = nsLength - inLength
Dim outString As String
outString = ""
Dim idx As Integer
idx = 0
While idx < inLength
Dim buf As Variant
buf = ns.Read(1&)
outString = outString &_
Mid$(hexChars, (buf(0) And &HF0&)/16+1,1) &_
Mid$(hexChars, (buf(0) And &HF&)+1,1)
idx = idx + 1
Wend
' Add another line of base64 output to the return string
notesStreamToHexBinary = notesStreamToHexBinary & outString & Chr$(13) & Chr$(10)
Wend
End Function
' Convert a hexBinary string into bytes in a NotesStream
Function hexBinaryToNotesStream (hexString As String) As NotesStream
Dim session As New NotesSession
Dim ns As NotesStream
Set ns = session.CreateStream
' variables used to stage output to the NotesStream
Dim buf (0 To 0) As Byte
Dim hexLen As Long
hexLen = Len(hexString)
Dim idx As Long
idx = 1
While idx <= hexLen
' Ignore whitespace (CR, LF, SPACE, or TAB) that may lead the line
Dim c As Long
c = Asc(Mid$(hexString, idx, 1))
If c = 13 Or c = 10 Or c = 32 Or c = 9 Then
idx = idx + 1
Goto Next1
End If
' Every 2 hexBinary characters represent 1 8-bit byte
buf(0) = 0
Dim i As Integer
For i = 0 To 1
buf(0) = buf(0) * 16
c = Asc(Mid$(hexString, idx+i, 1))
Select Case c
Case Asc("0") To Asc("9")
buf(0) = buf(0) + c - Asc("0")
Case Asc("A") To Asc("F")
buf(0) = buf(0) + c - Asc("A") + 10
End Select
Next
idx = idx + 2
Call ns.Write(buf)
next1:
Wend
done:
Set hexBinaryToNotesStream = ns
End Function
' Set the date part of a NotesDateTime From "CCYY-MM-DD ..."
' Uses localized date separators.
Sub setXSDDate (ndt As NotesDateTime, xsddate As String)
If Not ndt.IsValidDate Then ndt.LocalTime = ""
Dim timeonly As String
timeonly = ndt.TimeOnly ' preserve the time part
Dim s As New notessession
Dim intl As NotesInternational
Set intl = s.International
Dim datesep As String
Let datesep = intl.DateSep
Dim TmpDate As String
If (Intl.IsDateDMY) Then
TmpDate = Mid$(xsddate,9,2) 'Day
TmpDate = TmpDate & datesep &_
Mid$(xsddate,6,2) 'Month
TmpDate = TmpDate & datesep &_
Left$(xsddate,4) 'Year
Elseif (Intl.IsDateYMD) Then
TmpDate = Left$(xsddate,4) 'Year
TmpDate = TmpDate & datesep &_
Mid$(xsddate,6,2) 'Month
TmpDate = TmpDate & datesep &_
Mid$(xsddate,9,2) 'Day
Else
TmpDate = Mid$(xsddate,6,2) 'Month
TmpDate = TmpDate & datesep &_
Mid$(xsddate,9,2) 'Day
TmpDate = TmpDate & datesep &_
Left$(xsddate,4) 'Year
End If
ndt.LocalTime = TmpDate
End Sub
' Return the date part of a NotesDateTime as "CCYY-MM-DD"
Function getXSDDate (ndt As NotesDateTime) As String
If Not ndt.IsValidDate Then Error ErrTypeMismatch
Dim vdatetime As Varian