Xml 自定义排序:如果父节点包含子节点,我需要检查每个子节点属性名称,然后使用XSLT从该元素中提取文本
我在下面提到了我的示例xml文件。 我想以我自己的订单格式显示Xml 自定义排序:如果父节点包含子节点,我需要检查每个子节点属性名称,然后使用XSLT从该元素中提取文本,xml,xslt,Xml,Xslt,我在下面提到了我的示例xml文件。 我想以我自己的订单格式显示value标记文本。 例如:首先我想显示值AttributeID=“13222”然后 Value AttributeID=“113458”像这样,我需要根据AttributeID安排位置 Sample.xml <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl"?> <Values>
value
标记文本。
例如:首先我想显示值AttributeID=“13222”
然后
Value AttributeID=“113458”
像这样,我需要根据AttributeID安排位置
Sample.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"?>
<Values>
<Value AttributeID="113458" AttributeName="0180 - Text - remainder">
<Text>
<style name="TextHead1">The current enterprise application landscape</style>
<style name="TextStyle1">
<character name="linebreak" />Introduction of the Title
<style name="bold">
The smallest font size
<character name="linebreak" />
for which kerning should be automatically adjusted.
<character name="linebreak" />
and some manual work done.
</style>
<style name="bold">
Reference for this book<style name="superscript">1</style>
</style>
</Text>
</Value>
<Value AttributeID="13335" AttributeName="0190 - Text - remainder">
<Text>
<style name="TextHead1">The Bussiness application landscape</style>
<style name="TextStyle1">
Introduction of the Title
<style name="bold">
The smallest font size for which kerning should be automatically adjusted and some manual work done.
</style>
<style name="SimpleTag target="http://www.example.com/financing /uk""><style name="URL_bold">ibm.com</style></style>
<style name="italic">
Reference for this book<style name="superscript">1</style>
</style>
<style name="bulletStyle1">none: No leader line</style>
<style name="bulletStyle1">dot: Dotted leader line</style>
</Text>
</Value>
<Value AttributeID="13222" AttributeName="0200 - Text - remainder">
<Text>
<style name="TextHead1">the world’s largest florist and gift shop</style>
<style name="TextStyle1">
Introduction of the Title, It is also introducing environmental responsibility as a theme across all of its businesses,
The smallest font size for some manual work done.
<style name="SimpleTag target="http://www.example.com/financing /uk""><style name="URL_bold">ibm.com</style></style>
<style name="italic">
Reference for this book<style name="superscript">1</style>
</style>
<style name="bulletStyle1">environmental responsibility</style>
<style name="bulletStyle1">world’s largest florist</style>
</Text>
</Value>
</Values>
当前的企业应用程序环境
标题介绍
最小字体大小
应为其自动调整字距。
还有一些手工工作。
本书的参考文献1
商业应用前景
标题介绍
应自动调整字距并进行一些手动操作的最小字体大小。
ibm.com
本书的参考文献1
无:无引线
点:虚线引线
世界上最大的花店和礼品店
该公司还将环境责任作为其所有业务的主题,
一些手工操作的最小字体大小。
ibm.com
本书的参考文献1
环境责任
世界上最大的花店
以下是如何在XSLT中设置自定义排序的示例:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Values">
<values>
<xsl:for-each select="Value">
<xsl:sort data-type="number" order="ascending"
select="(number(@AttributeID='13222') * 1)
+ (number(@AttributeID='113458') * 2)
+ (number(@AttributeID='13335') * 3) "/>
<xsl:copy-of select="."/>
</xsl:for-each>
</values>
</xsl:template>
</xsl:stylesheet>
输入XML因为您的XML格式不正确:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"?>
<Values>
<Value AttributeID="113458" AttributeName="0180 - Text - remainder">
<Text>
<style name="TextHead1">The current enterprise application landscape</style>
<style name="TextStyle1">
<character name="linebreak" />Introduction of the Title
<style name="bold">
The smallest font size
<character name="linebreak" />
for which kerning should be automatically adjusted.
<character name="linebreak" />
and some manual work done.
</style>
<style name="bold">
Reference for this book<style name="superscript">1</style>
</style>
</style>
</Text>
</Value>
<Value AttributeID="13335" AttributeName="0190 - Text - remainder">
<Text>
<style name="TextHead1">The Bussiness application landscape</style>
<style name="TextStyle1">
Introduction of the Title
<style name="bold">
The smallest font size for which kerning should be automatically adjusted and some manual work done.
</style>
<style name="SimpleTag target="http://www.example.com/financing /uk""><style name="URL_bold">ibm.com</style></style>
<style name="italic">
Reference for this book<style name="superscript">1</style>
</style>
<style name="bulletStyle1">none: No leader line</style>
<style name="bulletStyle1">dot: Dotted leader line</style>
</style>
</Text>
</Value>
<Value AttributeID="13222" AttributeName="0200 - Text - remainder">
<Text>
<style name="TextHead1">the world’s largest florist and gift shop</style>
<style name="TextStyle1">
Introduction of the Title, It is also introducing environmental responsibility as a theme across all of its businesses,
The smallest font size for some manual work done.
<style name="SimpleTag target="http://www.example.com/financing /uk""><style name="URL_bold">ibm.com</style></style>
<style name="italic">
Reference for this book<style name="superscript">1</style>
</style>
<style name="bulletStyle1">environmental responsibility</style>
<style name="bulletStyle1">world’s largest florist</style>
</style>
</Text>
</Value>
</Values>
当前的企业应用程序环境
标题介绍
最小字体大小
应为其自动调整字距。
还有一些手工工作。
本书的参考文献1
商业应用前景
标题介绍
应自动调整字距并进行一些手动操作的最小字体大小。
ibm.com
本书的参考文献1
无:无引线
点:虚线引线
世界上最大的花店和礼品店
该公司还将环境责任作为其所有业务的主题,
一些手工操作的最小字体大小。
ibm.com
本书的参考文献1
环境责任
世界上最大的花店
生成的输出:
<?xml version="1.0" encoding="utf-8"?><values><Value AttributeID="13222" AttributeName="0200 - Text - remainder">
<Text>
<style name="TextHead1">the world’s largest florist and gift shop</style>
<style name="TextStyle1">
Introduction of the Title, It is also introducing environmental responsibility as a theme across all of its businesses,
The smallest font size for some manual work done.
<style name="SimpleTag target="http://www.example.com/financing /uk""><style name="URL_bold">ibm.com</style></style>
<style name="italic">
Reference for this book<style name="superscript">1</style>
</style>
<style name="bulletStyle1">environmental responsibility</style>
<style name="bulletStyle1">world’s largest florist</style>
</style>
</Text>
</Value><Value AttributeID="113458" AttributeName="0180 - Text - remainder">
<Text>
<style name="TextHead1">The current enterprise application landscape</style>
<style name="TextStyle1">
<character name="linebreak"/>Introduction of the Title
<style name="bold">
The smallest font size
<character name="linebreak"/>
for which kerning should be automatically adjusted.
<character name="linebreak"/>
and some manual work done.
</style>
<style name="bold">
Reference for this book<style name="superscript">1</style>
</style>
</style>
</Text>
</Value><Value AttributeID="13335" AttributeName="0190 - Text - remainder">
<Text>
<style name="TextHead1">The Bussiness application landscape</style>
<style name="TextStyle1">
Introduction of the Title
<style name="bold">
The smallest font size for which kerning should be automatically adjusted and some manual work done.
</style>
<style name="SimpleTag target="http://www.example.com/financing /uk""><style name="URL_bold">ibm.com</style></style>
<style name="italic">
Reference for this book<style name="superscript">1</style>
</style>
<style name="bulletStyle1">none: No leader line</style>
<style name="bulletStyle1">dot: Dotted leader line</style>
</style>
</Text>
</Value></values>
世界上最大的花店和礼品店
该公司还将环境责任作为其所有业务的主题,
一些手工操作的最小字体大小。
ibm.com
本书的参考文献1
环境责任
世界上最大的花店
当前的企业应用程序环境
标题介绍
最小字体大小
应为其自动调整字距。
还有一些手工工作。
本书的参考文献1
商业应用前景
标题介绍
应自动调整字距并进行一些手动操作的最小字体大小。
ibm.com
本书的参考文献1
无:无引线
点:虚线引线
那么你的问题是什么?是否希望值
元素按其属性ID按数字顺序排序?你说你想要13222
,然后是113458
,但是在这种情况下,13335
去哪里了?你能用XSLT创建XML到HTML并将所有样式添加到标记中吗,就像我在标记中提到的那样。你能使用和条件编码吗?你的问题只是关于排序。如果您需要XML到HTML输出,请创建另一篇包含输入和输出代码段要求的文章。