XML+Xslt 转换输出XML时元素属性间的换行问题
现在想转换后成生成如下格式:
<!-- 上传设定 -->
<Upload
userAvatarHost=""
userVerifyHost=""
productImageHost=""
productThumHost=""
userAvatarPath="~\Upload\Avatar\"
userVerifyPath="~\Upload\Verify\"
productImagePath="~\Upload\Image\"
productThumbPath="~\Upload\Thumb\"
userAvatarUrl="/Upload\Avatar\"
userVerifyUrl="/Upload\Verify\"
productImageUrl="/Upload/Image/"
productThumbUrl="/Upload\Thumb\"
/>
可是现在转换后的结果是
<!--上传设定-->
<Upload userAvatarHost="" userVerifyHost="" productImageHost="" productThumHost="" userAvatarPath="~\Upload\Avatar\" userVerifyPath="~\Upload\Verify\" ImagePath="~\Upload\Images\" ThumbPath="~\Upload\Thumbs\" userAvatarUrl="/Upload\Avatar\" userVerifyUrl="/Upload\Verify\" ImageUrl="/Upload/Images/" ThumbUrl="/Upload\Thumbs\" LogoUrl="test" />
有没有什么办法保留原来的换行呀?
xml文件应该是系统读的,因此节点属性间换行对它可能意义不大,因为无论是你预期的样式还是系统实际输出的样式,两个在 xml 阅读器下的内容应该是一致的。因此对你这个能否实现以及是否必要我保留看法。如果是想优化数据的结构,便于分组、分析、易读,建议将 Upload 的属性表达为三个子节点的属性。如
<Upload>
<Host
userAvatarHost=""
userVerifyHost=""
productImageHost=""
productThumHost=""
/>
<Path
userAvatarPath="~\Upload\Avatar\"
userVerifyPath="~\Upload\Verify\"
productImagePath="~\Upload\Image\"
productThumbPath="~\Upload\Thumb\"
/>
<Url
userAvatarUrl="/Upload\Avatar\"
userVerifyUrl="/Upload\Verify\"
productImageUrl="/Upload/Image/"
productThumbUrl="/Upload\Thumb\"
/>
/>