什么是条带错误?

发布于 2024-08-19 21:42:35 字数 759 浏览 4 评论 0原文

我正在尝试使用 xslt 将 last.fm xml 数据转换为 rdf 并收到此错误: ERROR [http-8080-1] (RDFDefaultErrorHandler.java:40) - (line 3 column 24): {E202} Expecting XML start或结束元素。不允许使用字符串数据“Joseph Arthur”。也许是条带错误。

谁能向我解释什么是条带错误,或者一般来说我做错了什么。

xslt 代码在这里:

    <xsl:for-each select="/lfm/artists/artist">
        <lfm:name><xsl:value-of select="name"/></lfm:name>
    </xsl:for-each>

这是 xml 位置: http://ws.audioscrobbler.com/2.0 /?method=library.getartists&api_key=b25b959554ed76058ac220b7b2e0a026&user=joanofarctan

谢谢。

I'm trying to convert last.fm xml data into rdf using xslt and am getting this error: ERROR [http-8080-1] (RDFDefaultErrorHandler.java:40) - (line 3 column 24): {E202} Expecting XML start or end element(s). String data "Joseph Arthur" not allowed. Maybe a striping error.

Can anyone explain to me what a striping error is, or in general what I'm doing wrong.

The xslt code is here:

    <xsl:for-each select="/lfm/artists/artist">
        <lfm:name><xsl:value-of select="name"/></lfm:name>
    </xsl:for-each>

Here's the xml location:
http://ws.audioscrobbler.com/2.0/?method=library.getartists&api_key=b25b959554ed76058ac220b7b2e0a026&user=joanofarctan

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧时光的容颜 2024-08-26 21:42:35

查看由此生成的完整 xml,或者至少是完整的 xslt 和输入 xml(其中没有提到“Joseph Arthur”)确实很有帮助。

因此,抛开所有这些,您正在生成的 rdf/xml 破坏了一个称为“条带化”的重要功能。 Dan Brickley 写了一个有用的解释,但这里有一个非常简短的总结:当与 rdf 一起呈现时/xml

<a>
  <b>
    <c>
      <d>

你知道奇数标签(a,c)对应于rdf图中的节点,而偶数标签(c,d)代表边或属性。语法“stripes”节点和属性。

此外,如果一个元素包含文本,它必须是一个属性(节点元素只包含其他元素,或者不包含任何元素)。

因此解析器认为它位于一个节点,因此期望更多元素,找到文本,并建议您在错误的位置使用属性。我的猜测是你的 rdf 看起来像:

<rdf:RDF ...>
  <lfm:name>Joseph Arthur</lfm:name>
  ....

你说过某些东西的属性名称值为“Joseph Arthur”,但你没有包含主题节点,所以我们不知道这个名称是什么。

It would really help to see the full xml produced by this, or at least the full xslt and input xml (which doesn't mention 'Joseph Arthur').

So setting all that aside, the rdf/xml you are producing is breaking an important feature called 'striping'. Dan Brickley wrote a useful explanation, but here's a very brief summary: when presented with rdf/xml

<a>
  <b>
    <c>
      <d>

you know that the odd tags (a, c) correspond to nodes in the rdf graph, whereas the even tags (c, d) represent edges, or properties. The syntax 'stripes' nodes and properties.

In addition, if an element contains text it must be a property (nodes elements only ever contain other elements, or nothing).

So the parser thought it was at a node, hence expected more elements, found text, and suggests you were using a property in the wrong place. My guess is your rdf looks like:

<rdf:RDF ...>
  <lfm:name>Joseph Arthur</lfm:name>
  ....

You've said something has the property name with value 'Joseph Arthur', but you haven't included a subject node, so we don't know what has this name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文