如何使用xquery在xml中添加和删除处理指令

如何使用xquery在xml中添加和删除处理指令,xml,xslt-1.0,xquery,Xml,Xslt 1.0,Xquery,我希望添加和删除与相同的处理指令 <?xml-stylesheet type="text/xsl" href="OtxViewer.xsl" ?> 使用xquery转换为xml文件,但我不能。 请帮助我找到解决方案?要删除处理指令,您可以复制除处理指令之外的所有顶级节点,例如: document { doc("file:/c:/Untitled1.xml")/node()[not(. instance of processing-instruction(xml-sty

我希望添加和删除与相同的处理指令

<?xml-stylesheet type="text/xsl" href="OtxViewer.xsl" ?> 

使用xquery转换为xml文件,但我不能。
请帮助我找到解决方案?

要删除处理指令,您可以复制除处理指令之外的所有顶级节点,例如:

document {
    doc("file:/c:/Untitled1.xml")/node()[not(. instance of processing-instruction(xml-stylesheet))]
}
document {
    processing-instruction xml-stylesheet {
        'type="text/xsl" href="OtxViewer.xsl"'
    },
    doc("file:/c:/Untitled1.xml")/node()
}
要添加处理指令,您可以将其插入新文档,然后从旧文档复制到顶级节点,例如:

document {
    doc("file:/c:/Untitled1.xml")/node()[not(. instance of processing-instruction(xml-stylesheet))]
}
document {
    processing-instruction xml-stylesheet {
        'type="text/xsl" href="OtxViewer.xsl"'
    },
    doc("file:/c:/Untitled1.xml")/node()
}

要删除处理指令,可以复制除处理指令之外的所有顶级节点,例如:

document {
    doc("file:/c:/Untitled1.xml")/node()[not(. instance of processing-instruction(xml-stylesheet))]
}
document {
    processing-instruction xml-stylesheet {
        'type="text/xsl" href="OtxViewer.xsl"'
    },
    doc("file:/c:/Untitled1.xml")/node()
}
要添加处理指令,您可以将其插入新文档,然后从旧文档复制到顶级节点,例如:

document {
    doc("file:/c:/Untitled1.xml")/node()[not(. instance of processing-instruction(xml-stylesheet))]
}
document {
    processing-instruction xml-stylesheet {
        'type="text/xsl" href="OtxViewer.xsl"'
    },
    doc("file:/c:/Untitled1.xml")/node()
}

你找不到的?你找不到的?