我意识到它并不优雅或不合适,但它是否允许(在格式良好的XML中)XML元素中的属性值跨越多行?
例如
<some-xml-element value="this value goes over....
multiple lines!" />
Run Code Online (Sandbox Code Playgroud)
是的,我意识到有更好的写作方式.我个人会写它:
<some-xml-element>
<value>this value goes over...
multiple lines!</value>
</some-xml-element>
Run Code Online (Sandbox Code Playgroud)
要么:
<some-xml-element value="this value goes over.... " />
Run Code Online (Sandbox Code Playgroud)
但是我们有自己的XML解析器,我想知道第一个例子是否在格式良好的XML中被允许.
我需要保存包含某些XML属性中的换行符的内容,而不是文本.应该选择该方法,以便我能够在XSLT 1.0/ESXLT/XSLT 2.0中对其进行解码
什么是最好的编码方法?
请建议/提出一些想法.
免责声明:以下是针对XML的罪行.这就是我试图用XSLT改变它的原因:)
我的XML目前看起来像这样:
<root>
<object name="blarg" property1="shablarg" property2="werg".../>
<object name="yetanotherobject" .../>
</root>
Run Code Online (Sandbox Code Playgroud)
是的,我将所有文本数据放在属性中.我希望XSLT能救我; 我想走向这样的事情:
<root>
<object>
<name>blarg</name>
<property1>shablarg</name>
...
</object>
<object>
...
</object>
</root>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我实际上已经完成了所有这些工作,除了我对XML的罪恶更加特殊.一些标签看起来像这样:
<object description = "This is the first line
This is the third line. That second line full of whitespace is meaningful"/>
Run Code Online (Sandbox Code Playgroud)
我在linux下使用xsltproc,但它似乎没有任何保留空格的选项.我试图使用xsl:preserve-space和xml:space ="preserve"无济于事.我发现的每个选项似乎都适用于在元素本身内保留空格,而不是属性.每一次,以上都改为:
This is the first line This is the third line. That second line full of whitespace is meaningful
所以问题是,我可以保留属性空白吗?
如何循环我在XSLT 1.0中作为参数传递的逗号分隔字符串?EX-
<xsl:param name="UID">1,4,7,9</xsl:param>
Run Code Online (Sandbox Code Playgroud)
我需要循环上面的UID参数并从我的XML文件中的每个UID中收集节点
我有以下xml文件:
<courses>
<course>
<name>Course 1</name>
<code>00162</code>
<questions>2,2,1,1,2,1,1,1</questions>
</course>
</courses>
Run Code Online (Sandbox Code Playgroud)
我需要查询文件(我使用xpath)来拆分'questions'元素,检查每个数字出现的位置,并检查它是否为数字1或2.
基本上我需要在xpath中这样做:
Dim ints As String() = QuestionsString.ToString.Split(",")
Dim i As Integer
For i = 0 To UBound(ints)
If ints(i) = "2" Then
'do something
Else
'do something else
End If
Next
Run Code Online (Sandbox Code Playgroud)
从评论更新
嗨,谢谢你.我打算编辑这个问题,因为它不正确.我想要得到的,例如,所有的课程名称和代码,其"问题"元素(拆分后)有"2"中的第二位置,在1,2,2,1,1,1,2,1谢谢!