我有一个XML文档,其根目录显示默认命名空间.像这样的东西:
<MyRoot xmlns="http://www.mysite.com">
<MyChild1>
<MyData>1234</MyData>
</MyChild1>
</MyRoot>
Run Code Online (Sandbox Code Playgroud)
由于默认命名空间,解析XML的XSLT无法按预期工作,即当我删除命名空间时,一切都按预期工作.
这是我的XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/" >
<soap:Envelope xsl:version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NewRoot xmlns="http://wherever.com">
<NewChild>
<ChildID>ABCD</ChildID>
<ChildData>
<xsl:value-of select="/MyRoot/MyChild1/MyData"/>
</ChildData>
</NewChild>
</NewRoot>
</soap:Body>
</soap:Envelope>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
XSLT文档需要做什么才能使翻译正常工作?在XSLT文档中究竟需要做什么?
拥有一个源xml文档,该文档使用包含前缀和默认命名空间的命名空间.当我使用XSLT doc对其进行转换时,生成的已翻译的xml文档不正确,即缺少源xml文档中的元素数据.
当我从源xml文档中删除"默认命名空间"时,转换按预期工作.
问题:有没有办法解决问题而无需编辑源xml文档中的默认命名空间?也就是说,将解决方案添加到XSLT文档中.
XML文档:
<MyElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.zolldata.com/UDX">
Run Code Online (Sandbox Code Playgroud)
问题默认命名空间的位置是xmlns ="http://www.zolldata.com/UDX"
我有以下内容并按此顺序:
<script type="text/javascript">
$(document).ready(function(){
var overwrite = $('#itemList input:radio:checked').val()
alert('value = '+ overwrite);
});
</script>
<body>
<form ..... >
<div id="itemList">
Overwrite?
<input type="radio" value="Yes" class="overWrite" name="overWrite" >Yes
<input type="radio" value="No" class="overWrite" name="overWrite" >No
</div>
</form>
</body>
Run Code Online (Sandbox Code Playgroud)
当它运行时,警报将具有'value = undefined'
但是,如果我将javascript放在div(或正文)之后,警报会返回'value = Yes'
为什么jquery在页面开头不能识别类型广播?如果我创建一个type ='hidden',jquery可以在页面开头读取/识别该值.当type ='radio'时,行为是不同的
我通过查看节点的值来循环.
If Node = B, then B has one of two possible meanings.
--If Node = A has been previously found in the file, then the value for A
should be sent as 1.
--If Node = A has NOT been found in the file, the the value for A should
be sent as 2.
where file is the xml source to be transformed
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚如何做到这一点.如果我使用的编程语言允许变量重新分配/更改其值,则很容易.但是,用XSLT变量设置一次.
xslt ×3
namespaces ×2
attributes ×1
default ×1
jquery ×1
loops ×1
radio-button ×1
undefined ×1
variables ×1