RRX SAX: </rdf:RDF> inside rdf:parseType="Literal" ends the document ("Inconsistent parserMode:TOP")

クローズ 初心者向け
#4,334 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@afs がすでに取り組んでいます。

2026年10月19日 から。

  • #4337 @afs による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
75/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
backend, databases

調査の方向性

issueで rdf:RDF のチェックとXMLリテラル収集のチェックの順序が誤っていると指摘されている ParserRRX_SAX.endElement から始めてください。XMLリテラル収集を先にチェックする startElement と比較し、問題を再現する入力でRDF/XMLパーサーを実行してください。デフォルトのSAXパーサーがその入力を受け入れ、結果が他に列挙されたパーサーと一致すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Version

6.1.0 (same code on main)

What happened?

An XML literal whose content contains an rdf:RDF element fails to parse with the default RDF/XML parser (RDFXML-SAX):

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="http://example.org/">
  <rdf:Description rdf:about="http://example.org/s">
    <ex:p rdf:parseType="Literal"><x xmlns="http://example.org/x"><rdf:RDF><rdf:Description rdf:about="http://example.org/inner"/></rdf:RDF></x></ex:p>
    <ex:q>after</ex:q>
  </rdf:Description>
</rdf:RDF>
$ riot --validate --syntax=RDFXML min.rdf
ERROR riot :: [line: 5, col: 21] Inconsistent parserMode:TOP

The document is valid RDF/XML. The content of a parseTypeLiteralPropertyElt is the literal symbol, "Any XML element content that is allowed according to [XML10] ... Rule [43] content" (RDF/XML §7.2.33), and "All information items contained inside XML elements matching the parseTypeLiteralPropertyElt production form XML literals and do not follow this mapping" (§6).

The other parsers agree with the spec. Parsing the same input:

parser result
RRX.RDFXML_StAX_ev ok, isomorphic
RRX.RDFXML_StAX_sr ok, isomorphic
RRX.RDFXML_ARP1 ok, isomorphic
RRX.RDFXML_SAX (default Lang.RDFXML) Inconsistent parserMode:TOP

Jena's own writer produces this form: an rdf:XMLLiteral whose lexical form contains <rdf:RDF> is written by RDFFormat.RDFXML_PLAIN as rdf:parseType="Literal" markup, so the default write cannot be read back by the default parser. Any rdf:RDF triggers it, even an empty <rdf:RDF/>; other rdf: elements in the literal (rdf:Description, rdf:Seq) parse fine.

Cause: in ParserRRX_SAX.endElement, the rdf:RDF check comes before the XML literal check:

public void endElement(String namespaceURI, String localName, String qName) {
    if ( qNameMatches(rdfNS, rdfRDF, namespaceURI, localName) ) {
        decIndent();
        parserMode(ParserMode.TOP);
        return;
    }
    ...
    if ( xmlLiteralCollecting() ) {

startElement checks xmlLiteralCollecting() first, so the literal's <rdf:RDF> is collected, but its </rdf:RDF> is not: it returns early, leaving the parser in TOP and the element depth one short, and a later end tag (</rdf:Description>, line 5) reaches the default branch of the mode switch. Testing xmlLiteralCollecting() before the rdf:RDF check, as startElement does, should fix it.

We hit it in LinkedDataHub, where a stored XML literal holds a SPARQL CONSTRUCT result as RDF/XML; every Jena client reading the containing document as RDF/XML failed.

Relevant output and stacktrace
ERROR riot :: [line: 5, col: 21] Inconsistent parserMode:TOP
Are you interested in making a pull request?

Yes

主要言語
Java
スター
1.5k
フォーク
729
平均マージ
1日 3時間
マージ済み PR(30日)
51

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/jena のほかの issue

apache/jena の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。