我正在尝试使用 xmllint 重新格式化我们的 VisualForce 代码。我的命令行是“xmllint --format --recover filename.page”。
虽然格式(尤其是脚本部分)效果很好,但所有带有顶点的标签都经过修改以消除“顶点”。
例如,“apex:page”被替换为“page.”。显然,这会使重新格式化变得无用。
在处理过程中,xmllint 提示命名空间。在下面的示例中,我只使用命名空间“ns”。请注意输出如何删除“ns”。
tgagne@ubuntu:~/tmp$ xmllint --format --recover a.xml
a.xml:1: namespace error : Namespace prefix ns on a is not defined
<ns:a>
^
<?xml version="1.0"?>
<a>
</a>
最佳答案
为了补充 collapsar 的答案,这里有一些在 Salesforce 的企业 WSDL 中使用的命名空间。从这些开始或查看他们发布的其他 WSDL 可能是个好主意。 (有关详细信息,请参阅 http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_partner.htm。)
xmlns:tns="urn:enterprise.soap.sforce.com"
xmlns:fns="urn:fault.enterprise.soap.sforce.com"
xmlns:ens="urn:sobject.enterprise.soap.sforce.com"
编辑:刚刚查看了我们 Apex 类的元数据并找到了这个可能有用的命名空间:
xmlns="http://soap.sforce.com/2006/04/metadata"
关于xml - 有人有 Salesforce 的 APEX 的 XML 命名空间吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8763661/