惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
T
Threat Research - Cisco Blogs
Cloudbric
Cloudbric
Recent Commits to openclaw:main
Recent Commits to openclaw:main
I
Intezer
Attack and Defense Labs
Attack and Defense Labs
P
Privacy International News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
Lohrmann on Cybersecurity
C
Cybersecurity and Infrastructure Security Agency CISA
V2EX - 技术
V2EX - 技术
AWS News Blog
AWS News Blog
O
OpenAI News
L
LINUX DO - 最新话题
N
News | PayPal Newsroom
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Latest news
Latest news
D
Darknet – Hacking Tools, Hacker News & Cyber Security
A
Arctic Wolf
Spread Privacy
Spread Privacy
G
GRAHAM CLULEY
T
Tor Project blog
博客园_首页
Know Your Adversary
Know Your Adversary
有赞技术团队
有赞技术团队
S
Secure Thoughts
美团技术团队
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
T
Tailwind CSS Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Visual Studio Blog
J
Java Code Geeks
Cisco Talos Blog
Cisco Talos Blog
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Security Affairs
Jina AI
Jina AI
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
宝玉的分享
宝玉的分享
量子位
Last Week in AI
Last Week in AI
月光博客
月光博客
罗磊的独立博客
S
SegmentFault 最新的问题

博客园 - roboth

转:“由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值”的解决方法 .net tostring format格式说明 - roboth 一、DIP简介(DIP--Dependency Inversion Principle): 请确认 &lt;Import&gt; 声明中的路径正确,且磁盘上存在该文件。 异步委托 Visual Studio 最常用的13个快捷键 H1N1:速饮配方 通过注册表获取文件的ContentType [转]解决ASP.NET Web Applicatio超时时间已到.在操作完成之前超时时间已过或服务器未响应 - roboth 在线创建pdf Route命令使用详解 电子书下载 买药记 抓取图片 xslt之<xsl:apply-templates - roboth - 博客园 盲人摸象 sql产生日历表 dom操作时机 js小技巧之访问元素属性
msdn之sp_xml_preparedocument
roboth · 2009-05-25 · via 博客园 - roboth

读取作为输入提供的可扩展标记语言 (XML) 文本,然后使用 MSXML 分析器 (Msxmlsql.dll) 对其进行分析,并提供分析后的文档供使用。分析后的文档对 XML 文档中的各节点(元素、属性、文本和注释等)的树状表示形式。

sp_xml_preparedocument 返回一个句柄,可用于访问 XML 文档的新创建的内部表示形式。该句柄在会话的持续时间内有效,或者通过执行 sp_xml_removedocument 使其在句柄失效前一直有效。

注意:
分析后的文档存储在 SQL Server 2005 的内部缓存中。MSXML 分析器占用 SQL Server 可用总内存的八分之一。若要避免内存不足,请运行 sp_xml_removedocument 以释放内存。
注意:
为了保持向后兼容性,sp_xml_preparedocument 将会折叠属性中的 CR (char(13)) 和 LF (char(10)) 字符,即使这些字符被实体化,也会执行折叠操作。
注意:
使用由 sp_xml_preparedocument 调用的 XML 分析器,便可分析内部 DTD 和实体声明。由于可使用恶意构造的 DTD 和实体声明执行拒绝服务攻击,因此,我们极力建议用户不要直接将 XML 文档从不可信的源传递到 sp_xml_preparedocument。用户减少此类攻击可能性的一种方法是检查中间层上 XML 文档内是否存在实体声明,然后在这些文档发送到存储过程之前拒绝它们。

Transact-SQL 语法约定

语法

sp_xml_preparedocument
        hdoc
        OUTPUT
        [ , xmltext ]
        [ , xpath_namespaces ] 

参数

hdoc

新创建文档的句柄。hdoc 是一个整数。

[ xmltext ]

是原来的 XML 文档。MSXML 分析器分析该 XML 文档。xmltext 是一个文本参数:char、nchar、varchar、nvarchar、text、ntext 或 xml。默认值为 NULL,在此情况下将创建一个空 XML 文档的内部表示形式。

注意:
sp_xml_preparedocument 只能处理文本或非类型化的 XML。如果将作为输入的实例值已经是类型化的 XML,首先将它转换为新的非类型化的 XML 实例,或者转换为一个字符串,然后传递该值作为输入。有关详细信息,请参阅类型化与非类型化的 XML。
[ xpath_namespaces ]

指定在 OPENXML 的行和列 XPath 表达式中使用的命名空间声明。xpath_namespaces 是一个文本参数:char、nchar、varchar、nvarchar、text、ntext 或 xml。

默认值为 <root xmlns:mp="urn:schemas-microsoft-com:xml-metaprop">。xpath_namespaces 通过格式正确的 XML 文档为在 OPENXML 中的 XPath 表达式中使用的前缀提供命名空间 URI。xpath_namespaces 声明必须使用前缀来引用命名空间 urn:schemas-microsoft-com:xml-metaprop;这将提供有关分析的 XML 元素的元数据。虽然可以使用这项技术来为元属性命名空间重新定义命名空间前缀,但该命名空间不会丢失。即使 xpath_namespaces 不包含这类声明,前缀 mp 依然对 urn:schemas-microsoft-com:xml-metaprop 有效。

返回代码值

权限

示例

A. 为格式正确的 XML 文档准备内部表示形式

以下示例向作为输入提供的 XML 文档的新建内部表示形式返回句柄:在对 sp_xml_preparedocument 的调用中,将使用默认的命名空间前缀映射。

复制代码
DECLARE @hdoc int
        DECLARE @doc varchar(1000)
        SET @doc ='
        <ROOT>
        <Customer CustomerID="VINET" ContactName="Paul Henriot">
        <Order CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00">
        <OrderDetail OrderID="10248" ProductID="11" Quantity="12"/>
        <OrderDetail OrderID="10248" ProductID="42" Quantity="10"/>
        </Order>
        </Customer>
        <Customer CustomerID="LILAS" ContactName="Carlos Gonzlez">
        <Order CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00">
        <OrderDetail OrderID="10283" ProductID="72" Quantity="3"/>
        </Order>
        </Customer>
        </ROOT>'
        --Create an internal representation of the XML document.
        EXEC sp_xml_preparedocument @hdoc OUTPUT, @doc
        -- Remove the internal representation.
        exec sp_xml_removedocument @hdoc

B. 为带 DTD 的格式正确 XML 文档准备内部表示形式

以下示例向作为输入提供的 XML 文档的新建内部表示形式返回句柄:存储过程根据文档中包含的 DTD 来验证装载的文档。在对 sp_xml_preparedocument 的调用中,将使用默认的命名空间前缀映射。

复制代码
DECLARE @hdoc int
        DECLARE @doc varchar(2000)
        SET @doc = '
        <?xml version="1.0" encoding="UTF-8" ?>
        <!DOCTYPE root
        [<!ELEMENT root (Customers)*>
        <!ELEMENT Customers EMPTY>
        <!ATTLIST Customers CustomerID CDATA #IMPLIED ContactName CDATA #IMPLIED>]>
        <root>
        <Customers CustomerID="ALFKI" ContactName="Maria Anders"/>
        </root>'
        EXEC sp_xml_preparedocument @hdoc OUTPUT, @doc

C. 指定命名空间 URI

以下示例向作为输入提供的 XML 文档的新建内部表示形式返回句柄:对 sp_xml_preparedocument 的调用将 mp 前缀保留到元属性命名空间的映射,并将 xyz 映射前缀添加到命名空间 urn:MyNamespace

复制代码
DECLARE @hdoc int
        DECLARE @doc varchar(1000)
        SET @doc ='
        <ROOT>
        <Customer CustomerID="VINET" ContactName="Paul Henriot">
        <Order CustomerID="VINET" EmployeeID="5"
        OrderDate="1996-07-04T00:00:00">
        <OrderDetail OrderID="10248" ProductID="11" Quantity="12"/>
        <OrderDetail OrderID="10248" ProductID="42" Quantity="10"/>
        </Order>
        </Customer>
        <Customer CustomerID="LILAS" ContactName="Carlos Gonzlez">
        <Order CustomerID="LILAS" EmployeeID="3"
        OrderDate="1996-08-16T00:00:00">
        <OrderDetail OrderID="10283" ProductID="72" Quantity="3"/>
        </Order>
        </Customer>
        </ROOT>'
        --Create an internal representation of the XML document.
        EXEC sp_xml_preparedocument @hdoc OUTPUT, @doc, '<ROOT xmlns:xyz="urn:MyNamespace"/>'

请参阅

posted @ 2009-05-25 11:53  roboth  阅读(344)  评论()    收藏  举报