XQueryを使用して親子関係を取得するために、クエリでXpathを使用することは可能ですか? メタデータ プロパティを使用EXEC sp_xml_preparedocument @hDoc OUTPUT, @XML, '<xmlns:ns="http://some_namespace"/>'
し、その後使用すると、正しい親子 ID の関係が得られます。つまり、
SELECT *
FROM OPENXML(@hDoc,'/ns:root/ns:component/ns:indicator')
WITH(
componentID INT '@mp:parentid',
indicatorID INT '@mp:id',
componentIndicatorType VARCHAR(5) '@sometype') componentIndicators
これは機能しますが、XQuery を使用する場合は、sp_xml_preparedocument なしでこれを使用し、代わりに次のようなインデックスを持つ xml 列に XML を格納するテーブルに直接アクセスします
;WITH XMLNAMESPACES (
'http://some_namespace' AS ns )
select
**** --> Here I would like to retrieve a parent -- child relation id
f.i.value(N'@sometype', N'nvarchar(100)') AS sometype
from dbo.xmldatatest AS T
cross apply T.xmldata.nodes('ns:root/ns:component/ns:indicator') as f(i)
xqueryを使用して属性としてxmlに明示的に持っていない場合、そのようなノード関係を取得することは可能ですか?
次に、GB+ サイズの xml ドキュメントがある場合のパフォーマンスとスケーラビリティに関連する推奨される方法 (OPENXML/XQuery) はありますか?