Accessに、自分のXSLTコードを含むフィールドを持つテーブルがあります。 XML文書をインポートしてXSLTを使用してテーブルから変換したい。しかし、私は次のエラーを取得する:XSLTを使用してXMLを変換する
'-2147467259 (800004005)' the stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed xml document
XMLバリデータでチェックが成功しました。
Private Sub btnImport_Click()
Dim StrFileName As String
Dim fd As FileDialog
Dim vrtSelectedItem As Variant
Dim strFile As String, strPath As String
Dim xmlDoc As New MSXML2.DOMDocument60, xslDoc As New MSXML2.DOMDocument60
Dim newDoc As New MSXML2.DOMDocument60
Dim daoRST As DAO.Recordset: Set daoRST = CurrentDb.OpenRecordset("Attachments"): Debug.Print daoRST.Fields("XML").Value:
Set xmlDoc = New MSXML2.DOMDocument60
Set newDoc = New MSXML2.DOMDocument60
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.InitialFileName = "C:\Users\1122335\Desktop\*.xml"
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
xslDoc.Load daoRST.Fields("XML").Value
' LOAD XML SOURCE
xmlDoc.Load vrtSelectedItem
' TRANSFORM SOURCE
xmlDoc.transformNodeToObject xslDoc, newDoc '<<ERROR HERE
newDoc.Save "C:\Users\1122335\Desktop\temp.xml"
' APPEND TO TABLES
On Error Resume Next
Application.ImportXML "C:\Users\1122335\Desktop\temp.xml", acAppendData
Next vrtSelectedItem
Else
End If
End With
End Sub
エラーは、この行で発生します。
xmlDoc.transformNodeToObject xslDoc, newDoc
変換に使用する直前に 'xslDoc'の内容を出力して質問に追加できますか?また、エラーメッセージについてはhttps://stackoverflow.com/questions/23629754/script16389-the-stylesheet-does-not-contain-a-document-element-the-stylesheetと同様のgoogleヒットを参照してください。 – Leviathan