创建 xslt 以合并重复的术语属性,然后删除
抱歉,如果在其他地方回答了这个问题,我确实查看了相关问题,但看不出它们与此有何关系。
我有一个这样的文件:
<?xml version="1.0" encoding="utf-8"?>
<Zthes>
<term>
<termId>1</termId>
<termUpdate>Add</termUpdate>
<termName>Science, Biological</termName>
<termType>Nd</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
<relation>
<relationType>USE</relationType>
<termId>OMITERM9998</termId>
<termName>Biological Sciences</termName>
</relation>
</term>
<term>
<termId>2</termId>
<termUpdate>Add</termUpdate>
<termName>Sciences, Biological</termName>
<termType>Nd</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
<relation>
<relationType>USE</relationType>
<termId>OMITERMO9999</termId>
<termName>Biological Sciences</termName>
</relation>
</term>
<term>
<termId>OMITERMO9998</termId>
<termUpdate>Add</termUpdate>
<termName>Biological Sciences</termName>
<termType>Pt</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
</term>
<term>
<termId>OMITERMO9999</termId>
<termUpdate>Add</termUpdate>
<termName>Biological Sciences</termName>
<termType>Pt</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
</term>
</Zthes>
是否可以编写一个遍历并合并所有 Pt 的 xlst?在这种情况下,这将导致第二个术语名称使用相同的 Pt 术语。他们使用的 ID 并不重要。每个 Nd 都会引用一个 Pt,不是每个 Pt 都会有 ND 引用它,并且 Pts 可以有多个 Nd 引用它们
感谢您的任何指点,我对这些事情感到绝望!
编辑:输出将是:
<?xml version="1.0" encoding="utf-8"?>
<Zthes>
<term>
<termId>1</termId>
<termUpdate>Add</termUpdate>
<termName>Science, Biological</termName>
<termType>Nd</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
<relation>
<relationType>USE</relationType>
<termId>OMITERM9998</termId>
<termName>Biological Sciences</termName>
</relation>
</term>
<term>
<termId>2</termId>
<termUpdate>Add</termUpdate>
<termName>Sciences, Biological</termName>
<termType>Nd</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
<relation>
<relationType>USE</relationType>
<termId>OMITERMO9998</termId>
<termName>Biological Sciences</termName>
</relation>
</term>
<term>
<termId>OMITERMO9998</termId>
<termUpdate>Add</termUpdate>
<termName>Biological Sciences</termName>
<termType>Pt</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
</term>
</Zthes>
这样 2 个 Nd 项与具有相同名称但不同 ID 的 2 个 Pt 项的关系被组合为仅与一个 Pt 项有关系的 2 个 Nd 项。只要将关系合并到第一个PT中,就可以删除第二个PT,这样就不会出现重复,但关系仍然完好无损?
apologies if this is answered elsewhere, I did look at the related questions but couldn't see how they related to this.
I have a file like this:
<?xml version="1.0" encoding="utf-8"?>
<Zthes>
<term>
<termId>1</termId>
<termUpdate>Add</termUpdate>
<termName>Science, Biological</termName>
<termType>Nd</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
<relation>
<relationType>USE</relationType>
<termId>OMITERM9998</termId>
<termName>Biological Sciences</termName>
</relation>
</term>
<term>
<termId>2</termId>
<termUpdate>Add</termUpdate>
<termName>Sciences, Biological</termName>
<termType>Nd</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
<relation>
<relationType>USE</relationType>
<termId>OMITERMO9999</termId>
<termName>Biological Sciences</termName>
</relation>
</term>
<term>
<termId>OMITERMO9998</termId>
<termUpdate>Add</termUpdate>
<termName>Biological Sciences</termName>
<termType>Pt</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
</term>
<term>
<termId>OMITERMO9999</termId>
<termUpdate>Add</termUpdate>
<termName>Biological Sciences</termName>
<termType>Pt</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
</term>
</Zthes>
Is it possible to write a xlst which goes through and merges all Pts? That would result, in this instance, there would be 2nd term names using the same Pt term. The id they use is not important. Every Nd will reference a Pt, not every Pt will have NDs referencing it, and Pts can have multiple Nds referencing them
Thanks for any pointers I am hopeless at these things!
Edit: the output would be:
<?xml version="1.0" encoding="utf-8"?>
<Zthes>
<term>
<termId>1</termId>
<termUpdate>Add</termUpdate>
<termName>Science, Biological</termName>
<termType>Nd</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
<relation>
<relationType>USE</relationType>
<termId>OMITERM9998</termId>
<termName>Biological Sciences</termName>
</relation>
</term>
<term>
<termId>2</termId>
<termUpdate>Add</termUpdate>
<termName>Sciences, Biological</termName>
<termType>Nd</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
<relation>
<relationType>USE</relationType>
<termId>OMITERMO9998</termId>
<termName>Biological Sciences</termName>
</relation>
</term>
<term>
<termId>OMITERMO9998</termId>
<termUpdate>Add</termUpdate>
<termName>Biological Sciences</termName>
<termType>Pt</termType>
<termStatus>Active</termStatus>
<termApproval>Approved</termApproval>
<termCreatedDate>20110414T07:23:26</termCreatedDate>
<termCreatedBy>admin</termCreatedBy>
<termModifiedDate>20110414T07:35:54</termModifiedDate>
<termModifiedBy>admin</termModifiedBy>
<termAttribute label="A-Z Entry"/>
</term>
</Zthes>
so that the relationship which 2 Nd terms had with 2 Pt terms with the same name, but different IDs, were combined into 2 Nd terms having a relationship with just one Pt term. As long as the relationships were merged into the first PT, the second PT could be deleted so that there would be no duplicates but the relationships would still be intact?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我编写了以下样式表:
当应用于
输出时,
一个交叉引用未正确解析,但我认为问题不在于 XSLT,而在于您的数据,其中您有OMITERM9998 < /code> ,然后是
OMITERMO9998
并带有前导0
。这有帮助吗?真实数据中的 ids 是否形状更好?或者您是否需要编码以某种方式去除前导零以匹配/交叉引用元素?I wrote the following stylesheet:
When applied to
the output is
so one cross reference is not resolved correctly but I think the problem is not with the XSLT but with your data where you have
<termId>OMITERM9998</termId>
but then<termId>OMITERMO9998</termId>
with a leading0
. Does that help? Are the ids in the real data in better shape? Or do you need to code to strip leading zeros somehow to match/cross reference elements?