Loading data with mlcp - namespace issue

时间秒杀一切 提交于 2019-12-10 16:54:57

问题


I'm trying to load rss data from Wordpress into MarkLogic database. The data is in the form of following:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.2/">

<item>
  <wp:post_id>1</wp:post_id>
  <wp:post_title>title 1</wp:post_title>
  <dc:creator>bob</dc:creator>
</item>
<item>
  <wp:post_id>2</title>
  <wp:post_title>title 1</wp:post_title>
  <dc:creator>john</dc:creator>
</item>
</rss>

However, when I run the mlcp command, I get following warning and data is not inserted into the database:

WARN mapreduce.ContentWriter: XDMP-DOCNONSBIND: No namespace binding for prefix wp
WARN mapreduce.ContentWriter: XDMP-DOCNONSBIND: No namespace binding for prefix dc

The mlcp command I used is:

./mlcp.sh import -host localhost -port 8088 -username admin -password admin -input_file_path  data.xml -mode local -input_file_type aggregates -aggregate_record_element item -aggregate_uri_id post_id -output_uri_prefix /resources/ -output_uri_suffix .xml

Any idea how I can fix this?

Thank you!

Seong


回答1:


Your test case has one malformed line: <wp:post_id>2</title>. When I fix that and mlcp-Hadoop2-1.2-3 with 7.0-4, I see one warning per item element:

15/01/12 14:16:14 WARN mapreduce.ContentWriter: XDMP-DOCNONSBIND: No namespace binding for prefix wp at /resources/1.xml line 2 15/01/12 14:16:14 WARN mapreduce.ContentWriter: XDMP-DOCNONSBIND: No namespace binding for prefix wp at /resources/2.xml line 2

This looks like an mlcp bug to me. Your namespace declarations are above the level of the item element, and they aren't being sent up to the server.

As a workaround, you could edit the XML. Or you could try http://marklogic.github.io/recordloader/ with something like this:

$ recordloader.sh -DCONNECTION_STRING=xcc://admin:admin@localhost:8088 \
    -DRECORD_NAME=item -DID_NAME="#AUTO" data.xml

See http://marklogic.github.io/recordloader/ for other options.




回答2:


It does look like an MLCP bug to me as well. However, before giving up, try adding a default namespace to the root element, so it would be like:

<rss version="2.0" xmlns="http://yournamespace.com/" 
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.2/">


来源:https://stackoverflow.com/questions/27911554/loading-data-with-mlcp-namespace-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!