Customer Portal

XMLExtract:Reading elements and attributes with same name 2

Comments 2

  • Avatar
    imriskal
    0
    Comment actions Permalink
    Hi, jfuentesve,

    XMLExtract is not exactly the right component for this task. I would use XMLReader where it is possible control mapping with xpath expressions. The mapping would be as following:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Context xpath="//n2:theme" outPort="0" namespacePaths='n1="http://www.w3.org/2005/Atom";n2="http://www.blabla.org/feed/2.0"'>
    <Mapping cloverField="field1" xpath="../../../n1:id"/>
    <Mapping cloverField="field4" xpath="@id"/>
    </Context>

    This way you can process files with many entries or with many themes or both.

    Best regards,
  • Avatar
    jfuentesve
    0
    Comment actions Permalink
    Hi, thank you for your response.

    Unfortunately I can not find such a reader of type XMLReader available, these are the ones I can choose from:

    XMLExtract
    XMLXPathReader


    I went ahead and implemented a solution using XMLXpathReader, but now Im dealing with a missing class that should be accesible from the plugins:


    Error loading graph:/opt/ds/jetty-cloverServer/sandboxes/csm/graph/tag-association-program.grf Can't create object of type XML_XPATH_READER with reason: net/sf/saxon/sxpath/XPathEvaluator


    I can run it locally from Eclipse and it works with a java test, but doesn't work once deployed in the server, anyways that is not related to the topic. (though some help is welcome)


    This is what I'm using with XMLXpathReader:

    Tha mapping:


    <Context xpath="/feed/entry" outPort="0" sequenceField="IndexKey" namespacePaths='"http://www.w3.org/2005/Atom";csm="http://www.blahblah.org/feed/2.0"'>
    <Mapping xpath="./id" cloverField="csm_id_uri"/>
    <Context xpath="./csm:review/csm:themes/csm:theme" parentKey="IndexKey" generatedKey="ThemeIndexKey" outPort="1">
    <Mapping xpath="./@id" cloverField="tag_id"/>
    </Context>
    </Context>


    The node usage:

    Screen shot 2013-01-29 at 11.07.03 AM.png

    The corresponding edges have these fields:

    csm_id_uri;IndexKey
    tag_id;ThemeIndexKey

    I had to invert the order of the ports from/to the reader and the hash join to choose the right master key, using the keys in the mapping for the matching, it works like a charm.

    We are using clover 3.2.1. engine and designer.

Please sign in to leave a comment.