SaxonJS发出过多的名称空间属性

问题描述 投票:0回答:1

使用SaxonJS时,我可以验证一下,它产生与Saxon相同的输出,但有一个警告。看来,即使不需要它们,SaxonJS也会为每个元素发出名称空间属性。我尝试调整exclude-result-prefixes,但这没有效果。

[SaxonJS 1.2.0输出

<CastVoteRecordReport xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="NIST_V0_cast_vote_records.xsd" xsi:schemaLocation="NIST_V0_cast_vote_records.xsd NIST_V0_cast_vote_records.xsd">
    <CVR xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="NIST_V0_cast_vote_records.xsd">
        <BallotStyleId xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="NIST_V0_cast_vote_records.xsd">_01-0052-01</BallotStyleId>
        <CreatingDeviceId xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="NIST_V0_cast_vote_records.xsd">rd</CreatingDeviceId>
        <CurrentSnapshotId xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="NIST_V0_cast_vote_records.xsd">i__a_aaaaaago</CurrentSnapshotId>
        <CVRSnapshot xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="NIST_V0_cast_vote_records.xsd" ObjectId="i__a_aaaaaago">
            <CVRContest xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="NIST_V0_cast_vote_records.xsd">
                <ContestId xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="NIST_V0_cast_vote_records.xsd">_1GO</ContestId>
                <Undervotes xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="NIST_V0_cast_vote_records.xsd">1</Undervotes>
            </CVRContest>
...

Saxon-EE版本9.8.0.12输出

<?xml version="1.0" encoding="UTF-8"?>
<CastVoteRecordReport xmlns="NIST_V0_cast_vote_records.xsd"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <CVR>
      <BallotStyleId>_01-0052-01</BallotStyleId>
      <CreatingDeviceId>rd</CreatingDeviceId>
      <CurrentSnapshotId>i__a_aaaaaago</CurrentSnapshotId>
      <CVRSnapshot ObjectId="i__a_aaaaaago">
         <CVRContest>
            <ContestId>_1GO</ContestId>
            <Undervotes>1</Undervotes>
         </CVRContest>
...

SaxonJS.Transform的回调是

var transformCallback = (fragment: DocumentFragment) => {
            // have to convert to string?
            var div = document.createElement('div');
            div.appendChild(fragment.cloneNode(true));
            // replace existing output content
            that.outputText(div.innerHTML);
}
xml-namespaces saxon saxon-js
1个回答
0
投票
就XDM数据模型而言,XML和XSI命名空间的确应在结果树中每个元素的范围内;一个好的序列化程序将消除多余的名称空间。因此,所有这些都是关于如何对结果树进行序列化的问题。

(请注意,Saxon-JS 2.0是测试的最后阶段,它将具有完整的序列化程序。)

© www.soinside.com 2019 - 2024. All rights reserved.