需要使用 XSLT 创建元素
我想使用 xslt 1.0 在 xml
中创建一个元素。
这就是我在 xslt 中所做的
<xsl:variable name="width-value">12700</xsl:variable>
<xsl:element name="a:ln">
<xsl:attribute name="w">
<xsl:value-of select="$width-value"/>
</xsl:attribute>
</xsl:element>
抛出错误,
You cannot call an attribute 'w''
FATAL ERROR: 'Could not compile stylesheet' javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:825)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:614)
at com.vignesh.main.convert(main.java:288)
at com.vignesh.main.main(main.java:70)
I want to create a Element in xml <a:ln w="12700">
using xslt 1.0.
and this is what i did in xslt
<xsl:variable name="width-value">12700</xsl:variable>
<xsl:element name="a:ln">
<xsl:attribute name="w">
<xsl:value-of select="$width-value"/>
</xsl:attribute>
</xsl:element>
its throwing error,
You cannot call an attribute 'w''
FATAL ERROR: 'Could not compile stylesheet' javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:825)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:614)
at com.vignesh.main.convert(main.java:288)
at com.vignesh.main.main(main.java:70)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我唯一看到的是您缺少
a
的命名空间声明:如果我必须使此代码段正常工作,我必须添加类似这样的内容也许您有
a
code> 其他地方的命名空间声明。我怀疑问题是由于 XSL 的其他部分造成的,因为这个代码片段对我来说看起来没问题。The only thing that I see is that you're missing the namespace declaration for
a
: If I have to make this snippet working, I must add something like thisPerhaps you have the
a
namespace declaration elsewhere. I suspect the problem is due to some other part of your XSL, because this snippet looks OK to me.