Child nodes as document object

I have a xml document as follows:
<Root>
<Header><Name></Name></Header>
<Message><Type></Type></Message>
</Root>
I can read entire xml file into document object. Now I want to take only <Message> elements (Including Message child nodes) into document object, How can I do that.

There's a usable xml parser API in Java core library.

Similar Messages

  • How to create a Child node in Tree object

    Hi All,
    I have a thought to create a tree with a child object, that the child can able to create through by right click the parent tree having the options to create or delete the child objects.Please Suggest me if  there is an possible way.
    Thanks
    Gopinath

    Look at sample programm BCALV_TREE_DEMO,
    and especially at the methods ADD_NODE or  DELETE_SUBTREE of class CL_GUI_ALV_TREE.
    For implementing the context menu, consider event ITEM_CONTEXT_MENU_REQUEST.
    Regards,
    Ulrich

  • How to fetch the child Nodes using XNode

    Hi All,
    How to fetch child nodes of XNode object ?
    I am moving my code to .net 3.5 so i was replacing XMLNode to XNode , but i could find any ChildNodes() method.
    Thanks,
    Pallavi

    As such this  is not a  SharePoint related question, even though there are many way to parse the XNode object. 
    One way is,
    XNode an all other are derived from XElement, so you can use Linq to get all children by casting it with XElement, below is a snippet
    XDocument doc = XDocument.Load(""); //Path
    XElement ele = doc.Nodes().First() as XElement;//Just taking the first element as XNode
    foreach (var item in ele.Elements())
    var v = item;
    You can use Full Linq queries to find any node, just for example, below is a snipped to find a node based on a attribute value
    ele.Elements().Where(x => x.Attribute("text").Value == "text");
    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

  • Need to chart attribute value of just one child node of XML document

    I have a XML document with (for example) 7 parent nodes, each
    parent node has 5 child nodes. The parent nodes have an attribute
    @EarlierDTS (DateTime type) that is the x-axis category of a chart.
    Each child node has an attribute @eventid which specifies the id of
    the event, and another atttribute @NumOccurs which specifies how
    many times that event occured in that period.
    How do I tell Flex I want a simple line chart of the eventID
    = 215? What if I want two lines, for both eventID=215 and
    eventid=307?
    I have studied the posts and blogs for over a week now, and
    have seen this question or similar come up quite a few places, with
    no answer.
    1) Should I focus on learning how to create a filterfunction
    for the XMLList that underlies my XMLListCollection so that the
    filtered data view is just one child node per parent node ( or two
    child nodes for the second case)? And set the filtered data view as
    the dataprovider of my chart's vertical series?
    2) Should I focus on learning how to create a XML Filter
    query that selects just one or two child nodes for each parent
    node, and set the charts' series' dataprovider to this filter
    expression? (I don't think this is allowed - but I'm checking with
    the forum members...)
    3) Should I focus on learning how to convert the
    XMLListCollection into a HierarchicalData object, and then learning
    how to filter this object so there is only one (or two) childs per
    parent? This seems like a lot of coding - I almost have to create a
    pair of classes - one for the parent and one for the child - so I
    can create nested ArrayObjects.
    4) Should I create a brand new XMLList by walking the
    original XML list, and inserting Parent nodes and just the child
    nodes that match the eventID(s) I want to chart, into the new
    XMLList?
    I believe that the easiest way would be to create a
    Filterfunction for the XMLList, and bind the chart series to the
    (filtered) XML List. But the problem with this approach is that I
    have seen more than 2 posts asking how to accomplish filtering that
    removes specific children from the view, with no solutions posted.
    Help! What is the best way to get just one child for each
    parent, from an XMLList?

    "whertzing" <[email protected]> wrote in
    message
    news:[email protected]...
    >I have a XML document with (for example) 7 parent nodes,
    each parent node
    >has 5
    > child nodes. The parent nodes have an attribute
    @EarlierDTS (DateTime
    > type)
    > that is the x-axis category of a chart. Each child node
    has an attribute
    > @eventid which specifies the id of the event, and
    another atttribute
    > @NumOccurs
    > which specifies how many times that event occured in
    that period.
    >
    > How do I tell Flex I want a simple line chart of the
    eventID = 215? What
    > if I
    > want two lines, for both eventID=215 and eventid=307?
    >
    > I have studied the posts and blogs for over a week now,
    and have seen this
    > question or similar come up quite a few places, with no
    answer.
    >
    > 1) Should I focus on learning how to create a
    filterfunction for the
    > XMLList
    > that underlies my XMLListCollection so that the filtered
    data view is just
    > one
    > child node per parent node ( or two child nodes for the
    second case)? And
    > set
    > the filtered data view as the dataprovider of my chart's
    vertical series?
    >
    > 2) Should I focus on learning how to create a XML Filter
    query that
    > selects
    > just one or two child nodes for each parent node, and
    set the charts'
    > series'
    > dataprovider to this filter expression? (I don't think
    this is allowed -
    > but
    > I'm checking with the forum members...)
    >
    > 3) Should I focus on learning how to convert the
    XMLListCollection into a
    > HierarchicalData object, and then learning how to filter
    this object so
    > there
    > is only one (or two) childs per parent? This seems like
    a lot of coding -
    > I
    > almost have to create a pair of classes - one for the
    parent and one for
    > the
    > child - so I can create nested ArrayObjects.
    >
    > 4) Should I create a brand new XMLList by walking the
    original XML list,
    > and
    > inserting Parent nodes and just the child nodes that
    match the eventID(s)
    > I
    > want to chart, into the new XMLList?
    >
    > I believe that the easiest way would be to create a
    Filterfunction for the
    > XMLList, and bind the chart series to the (filtered) XML
    List. But the
    > problem
    > with this approach is that I have seen more than 2 posts
    asking how to
    > accomplish filtering that removes specific children from
    the view, with no
    > solutions posted.
    >
    > Help! What is the best way to get just one child for
    each parent, from an
    > XMLList?
    I'd just look at a dataFunction. There's an example here that
    may point you
    in the right direction:
    http://flexdiary.blogspot.com/2008/08/charting-example.html
    HTH;
    Amy

  • Problem with childs nodes and automatic key mapping in a Data Object

    Hi experts!
    I'm doing the service order tutorial from the mobile help at [this link|http://help.sap.com/saphelp_nwmobile71/helpdata/en/21/9b5b924c3b434fba4767731794b029/frameset.htm] and I have a problem...
    In the topic "Modeling the Equipment Data Object", says you have to mark the "Automatic Key Mapping" checkbox. So when I had to create a third child node ( the location node ) the system raised an exception with the message "Deselect automatic key mapping flag for more than two-level nodes". I'm trying deselecting the flag and creating the location node, but when I want mark again the automatic key mapping flag, this is disabled.
    What can I do to solve this and create the three child nodes with the flag marked? It's a configuration thing?
    Any help it's very welcome. Thanks in advance.
    Best regards,
    Simon.

    The thing is: Its not allowed to use automatic keymapping if you have more than two levels. This is why the message showed up, and this is why its been disabled.
    What automatic keymapping does: Figures out automatically which child node belongs to which parent (by guessing from the field name and type, which fields in the child correspond to which key fields of the parent).
    On three levels, this becomes more complicated => Its disabled.
    How to do keymapping yourself instead of having the DOE do it automatically: Do 'Explicit keymapping' from each child to its parent. Explicit keymapping is done by clicking on the corresponding menu button in the child node. Here you need to associate child node fields (they need not be key fields of the child, but they are allowed to be that as well) to each of its parent nodes key fields (so that each child can be associated to its parent).
    Cheers

  • How to append an xml string as a child node to a dom document

    Hi
    I have an xml represented as a String. Now I want to add this xml string as a child node to another DOM Document.
    Do I have to first parse the xml String into a xml Document and then add the nodes to the existing Document. Is there a simpler way to do this. Any input is appreciated.
    Many thanks in advance.

    radsat wrote:
    Hi
    I have an xml represented as a String. Now I want to add this xml string as a child node to another DOM Document.
    Do I have to first parse the xml String into a xml Document and then add the nodes to the existing Document. yes, this is what you need to do.
    Is there a simpler way to do this. Any input is appreciated.no, there really isn't, sorry.

  • Document(object, node-set)

    Using xsql 1.0.4.1, I'm having some trouble using the document(object, node-set) function defined in the XSLT 1.0 recommendation, sect 12.1:
    http://www.w3.org/TR/xslt#function-document
    I have a tag in my source xml document which contains a reference to another xml document. I want to construct an XPath expression for this other xml document. The path to the other xml document is specified relative to the source document.
    I'm doing something like this:
    Source Document:
    <blah>
    <some-tag redirect="answer.xml" />
    </blah>XSL:
    <xsl:template match="blah/some-tag">
    <xsl:variable name="redir" select="document(@redirect, / )" />
    <xsl:apply-templates select="$redir//somepath" />
    </xsl:template>
    ...However, Oracle XSLT always comes back with the following error:
    XSL-1013: Error in expression 'document(@redirect, / )'.I also get this error if I try
    document(@redirect, document(''))which is given as an example on pg 446 of Steve's book (but not what I want, since it resolves relative to the stylesheet).
    document(@redirect)works fine, but again is not what I want.
    Am I doing something wrong?
    Brian

    This is Oracle Bug# 1722555, hopefully which will be fixed in the 9.0.1.0.0 release. Currently the two-argument version of the document() function is not recognized properly.

  • How do I create multiple types of child nodes in ADF  Faces Tree Component

    Hi,
    I am trying to construct a tree using ADF Faces. The tree I am trying to develop should look something like:
    - Departments
    + Dept 10
    + Dept 20
    + Dept 30
    + Dept 40
    - Employees
    + SCOTT
    +ALLEN
    + BLAKE
    The nodes shown at the top level should serve as labels, indicating the various types of nodes available.
    I have created the top level RootLabelsViewObj, with a SQL clause:
    select rn, node_label
    from (
    select 1 rn
    , 'Employees' node_label
    from dual
    union all
    select 2 rn
    , 'Departments' node_label
    from dual
    union all
    select 3 rn
    , 'Bonusplans' node_label
    from dual
    I have created ViewLinks between the RootLabelsViewObj and the DeptView and EmpView respectively (created on top of DEPT and EMP table in SCOTT schema), based on the LABEL attribute in the RootLabelsViewObj and with ViewLink SQL specified like:
    :Bind_NodeLabel = 'Departments' for the link with DeptView and :Bind_NodeLabel = 'Employees' for the link with EmpView.
    In the ADF BC Application Module Tester, I get exactly what I want.
    However, when I create a JSF JSPX page and drag the RootLabelsViewObj from the Data Control Panel to the page as ADF Tree, I run into a little issue: it seems like I cannot create a second Branch Accessor rule for the RootLabelsViewObj1: I have created a first Branch Accessor Rule referring to DeptView and now try to create a second one for EmpView, to allow Employees to be displayed under the root label "Employees" - but I cannot.
    The PageDefinition looks like:
    <tree id="RootLabelsViewObj1" IterBinding="RootLabelsViewObj1Iterator">
    <AttrNames>
    <Item Value="Rn"/>
    <Item Value="NodeLabel"/>
    </AttrNames>
    <nodeDefinition DefName="model.RootLabelsViewObj"
    id="RootLabelsViewObjNode">
    <AttrNames>
    <Item Value="NodeLabel"/>
    </AttrNames>
    <Accessors>
    <Item Value="DeptView"/>
    </Accessors>
    </nodeDefinition>
    <nodeDefinition DefName="model.EmpView" id="EmpViewNode">
    <AttrNames>
    <Item Value="Ename"/>
    </AttrNames>
    </nodeDefinition>
    <nodeDefinition DefName="model.DeptView" id="DeptViewNode">
    <AttrNames>
    <Item Value="Deptno"/>
    </AttrNames>
    </nodeDefinition>
    </tree>
    Does anyone know:
    - whether it is possible (intended) to have more than one branch accessor per node (i.e. more than one type of child under a node in the tree)
    - if so, how this can be achieved?
    Right now it looks like I am limited to each node in the tree having only one type of child node.
    Please tell me I am wrong.
    best regards,
    Lucas

    Give this a shot mate
    event.getNativeEventTarget();That will allow you to access the DOM object directly
    Id can be retrieved via
    event.getNativeEventTarget().id;

  • Is it possible to restrict the user from creating a sibling and allow him to ONLY create child nodes in DRM?

    When in a hierarchy, a user right clicks on a node to crate a new node, he has two options
    -Child
    -Sibling
    Is it possible to restrict the user from creating a sibling and allow him to ONLY create child nodes?
    Business cases:
    1. different level nodes need to have different prefixes.
    - Thus, the default prefix property definition uses the level number to assign a prefix
    - Also, a validation, to ensure the correct prefix, uses the level number
    But if the user can create a child and a sibling then the default prefix will only be right for a single case and not both.
    Thanks

    If the images are exactly the same size then make sure the layer with the mask
    is the active layer and in the other documents go to Select>Load Selection and choose
    your document with the layer mask under Source document and under channel choose the layer mask.
    After the selection loads press the layer mask icon at the bottom of the layers panel.
    MTSTUNER

  • Getting Error while creating Document object  after  parsing XML String

    Hi All,
    I have been trying to parse an XML string using the StringReader and InputSource interface but when I am trying to create Document Object using Parse() method getting error like
    [Fatal Error] :2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    seorg.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    Please find the code below which i have been experimenting with:
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.StringReader;
    import java.util.List;
    import java.util.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import java.io.*;
    public class TestMain {
         public static void main(String[] args) {
              String file = "";
              file = loadFileContent("C:\\Test.xml");
              System.out.println("contents >> "+file);
              parseQuickLinksFileContent(file);
    public static void parseQuickLinksFileContent(String fileContents) {
    PWMQuickLinksModelVO objPWMQuickLinksModelVO = new PWMQuickLinksModelVO();
         try {
    DocumentBuilderFactory factory =           DocumentBuilderFactory.newInstance();
         DocumentBuilder builder = factory.newDocumentBuilder();
         StringReader objRd = new StringReader(fileContents);
         InputSource objIs = new InputSource(objRd);
         Document document = builder.parse(objIs); // HERE I am getting Error.
         System.out.println(document.toString());
    What is happening while I am using builder.parse() method ???
    Thanks,
    Rajendra.

    Getting following error
    [Fatal Error] :2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    seorg.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.

  • IF_IXML : How can i add encoding with value UTF-8 to the document object??

    Hi
    i want to create a xml file with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <OpenSearchDescription xmlns="http://...."> 
    </OpenSearchDescription>
    i did this with the if_ixml interface and rendered the content in a file 'D:\usr\sap\IFD\DVEBMGS01\log\TEST_out.xml
    <?xml version="1.0"?>
    <OpenSearchDescription xmlns="http://...."> 
    </OpenSearchDescription>
    BUT the document attribut(?) encoding="UTF-8"?> is missing!
    How can i add encoding with value UTF-8 to the document object?? it should look like:
    <?xml version="1.0" encoding="UTF-8"?>
    *here is my coding.
    TYPE-POOLS: ixml.
    CLASS cl_ixml DEFINITION LOAD.
    DATA: lo_ixml           TYPE REF TO if_ixml,
          lo_streamfactory  TYPE REF TO if_ixml_stream_factory,
          lo_document       TYPE REF TO if_ixml_document,
          lo_parent         TYPE REF TO if_ixml_element,
          lo_ostream        TYPE REF TO if_ixml_ostream,
          lo_renderer       TYPE REF TO if_ixml_renderer,
         lv_rc           TYPE i.
    lo_ixml = cl_ixml=>create( ).
    lo_streamfactory = lo_ixml->create_stream_factory( ).
    lo_document = lo_ixml->create_document( ).
    lo_parent = lo_document->create_simple_element( name   = 'OpenSearchDescription'  "root node
                                                    parent = lo_document ).
    lo_parent->set_attribute_ns( name   =  'xmlns'
                                 value  = 'http://....' ).
    *rausrendern in file
    lo_ostream = lo_streamfactory->create_ostream_uri( system_id = 'D:\usr\sap\IFD\DVEBMGS01\log\TEST_out.xml' ).
    lo_renderer = lo_ixml->create_renderer( ostream  = lo_ostream
                                            document = lo_document ).
    lv_rc = lo_renderer->render( ).
    Thanks for help
    Britta

    Use the following code:
    set an document encoding
      l_encoding = l_ixml->create_encoding( character_set = 'UTF-8'
                                            byte_order = if_ixml_encoding=>co_none ).
      l_success  = l_ostream->set_encoding( encoding = l_encoding ).
    create a xml renderer
      l_renderer = l_ixml->create_renderer( document = l_doc ostream  = l_ostream ).

  • How to differentiate parent and child node in af:treeTable ?

    Greetings,
    I have a requirement, I display master child view objects using <af:treeTable> component, When user expands a parent row, I have to make parent row is in read only and expanded(child) row in editable. To accomplish this I have to identify the 'node' whether it belongs to parent or child view object. In this example Tree table binds with EmpVO, There is a view link beteween EmpVO and DepartmentVO.
    <af:treeTable value="#{bindings.EmpVO.treeModel}"
    var="node"
    rowSelection="single" id="tEqSum"
    summary="Employee Summary"
    <af:column sortProperty="#{bindings.EmpVO.hints.LocCity.name}"
    filterable="true" sortable="true" width="90"
    headerText="#{bindings.EmpVO.hints.LocCity.label}"
    id="c3">
    <af:outputText value="#{node.LocCity}" id="ot21"/>
    expandAllEnabled="false">
    </af:treeTable>
    Thanks in Advance,

    Hi,
    You can find out the node depth by using
    #{bindings.<your_tree_binding>.treeModel.depth}Based on the depth, you can decide whether its a parent node or child node (for a 1 level tree- say dept and emp, the depth for parent would be 0 and for the child it would be 1).
    -Arun

  • How to remove empty lines from xml files after removing nodes from document

    <pre>
    Hi
    <b>i have xml document, which is shown below
    after removing some nodes from the document ,i am getting empty lines in place of removed nodes,how to resolve this and get the proper xml document without any errors</b>
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE Message SYSTEM "TRD01.dtd">
    <Message>
    <Header>
    <CounterPartyType>CLIENT</CounterPartyType>
    <CreationTime>20134455</CreationTime>
    <ErrorCode>363 </ErrorCode>
    <ErrorEnterPriseId>N</ErrorEnterPriseId>
    <ErrorStatus>1</ErrorStatus>
    <ErrorSystemId>STL</ErrorSystemId>
    <ErrorTimes>31</ErrorTimes>
    <MessageType>T</MessageType>
    <RecipientEnterpriseId>N</RecipientEnterpriseId>
    <RecipentSystemId>EXM</RecipentSystemId>
    <Remarks>REMARSK</Remarks>
    <SenderEnterpriseId>N</SenderEnterpriseId>
    <SenderSystemId>TR</SenderSystemId>
    </Header>
    </Message>
    <ErrorCode>363 </ErrorCode>
    <ErrorEnterPriseId>NIHK</ErrorEnterPriseId>
    <ErrorStatus>1</ErrorStatus>
    <ErrorSystemId>STL</ErrorSystemId>
    <ErrorTimes>31</ErrorTimes>
    XPathExpression expression5 = xpath.compile(xmlpath5);
    Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
    Node node5 = (Node) result5;
    node5.getParentNode().removeChild(node5);
    XPathExpression expression6 = xpath.compile(xmlpath6);
    Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
    Node node6=(Node) result6;
    node6.getParentNode().removeChild(node6);
    XPathExpression expression7 = xpath.compile(xmlpath7);
    Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
    Node node7=(Node) result7;
    node7.getParentNode().removeChild(node7);
    doc.normalize();
    doc.normalizeDocument();
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    t.setOutputProperty(OutputKeys.METHOD,"xml");
    t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    the xml output i am getting is
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <Message>
    <Header>
    <CounterPartyType>CLIENT</CounterPartyType>
    <CreationTime>20134455</CreationTime>
    <MessageType>TRD01</MessageType>
    <RecipientEnterpriseId>N</RecipientEnterpriseId>
    <RecipentSystemId>STL</RecipentSystemId>
    <Remarks>REMARSK</Remarks>
    <SenderEnterpriseId>N</SenderEnterpriseId>
    <SenderSystemId>T</SenderSystemId>
    </Header>
    </Message>
    <b>could you please let me know how to avoid empty lines in the xml doucment output</b>
    this is the method i am using to get the result
    public void ValidateRecord(String xml){
    try{
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = factory.newDocumentBuilder();
    //parse file into DOM
    /*DOMParser parser = new DOMParser();
    parser.setErrorStream(System.err);
    parser.setValidationMode(DTD_validation);
    parser.showWarnings(true);*/
    System.out.println ("HI THIS xml is validation "+xml);
    Resolver res = new Resolver();
    db.setEntityResolver(res);
    Document doc = db.parse(new InputSource(new StringReader(xml)));
    XPathFactory xpf = XPathFactory.newInstance();
    XPath xpath = xpf.newXPath();
    // XPathExpression expression = xpath.compile("//A/B[C/E/text()=13]");
    String xmlpath="/Message/Header/CounterPartyType/text()";
    String xmlpath1="/Message/Header/RecipentSystemId/text()";
    String xmlpath2="/Message/Header/ErrorSystemId/text()";
    XPathExpression expression = xpath.compile(xmlpath);
    XPathExpression expression1 = xpath.compile(xmlpath2);
    Object result = expression.evaluate(doc, XPathConstants.NODE);
    Object result1 = expression1.evaluate(doc, XPathConstants.NODE);
    Node node = (Node) result;
    Node node1 = (Node) result1;
    System.out.println("the values of the string is " +node.getNodeValue());
    System.out.println("the values of the string is " +node1.getNodeValue());
    // for (int i = 0; i < nodes.getLength(); i++) {
    //System.out.println(nodes.item(i).getNodeValue());
    // CAHNGING THE RECEIPENT NODE
    XPathExpression expression2 = xpath.compile(xmlpath1);
    Object result2 = expression2.evaluate(doc, XPathConstants.NODE);
    Node node2 = (Node) result2;
    System.out.println(node2);
    node2.setNodeValue(node1.getNodeValue());
    System.out.println(node2);
    //removing the nodes from document
    String xmlpath3="/Message/Header/ErrorCode";
    String xmlpath4="/Message/Header/ErrorEnterPriseId";
    String xmlpath5="/Message/Header/ErrorStatus";
    String xmlpath6="/Message/Header/ErrorSystemId";
    String xmlpath7="/Message/Header/ErrorTimes";
    XPathExpression expression3 = xpath.compile(xmlpath3);
    Object result3 = expression3.evaluate(doc, XPathConstants.NODE);
    Node node3 = (Node) result3;
    node3.getParentNode().removeChild(node3);
    XPathExpression expression4 = xpath.compile(xmlpath4);
    Object result4 = expression4.evaluate(doc, XPathConstants.NODE);
    Node node4 = (Node) result4;
    System.out.println("node value");
    System.out.println(node4.getParentNode().getNodeName());
    node4.getParentNode().removeChild(node4);
    XPathExpression expression5 = xpath.compile(xmlpath5);
    Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
    Node node5 = (Node) result5;
    node5.getParentNode().removeChild(node5);
    XPathExpression expression6 = xpath.compile(xmlpath6);
    Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
    Node node6=(Node) result6;
    node6.getParentNode().removeChild(node6);
    XPathExpression expression7 = xpath.compile(xmlpath7);
    Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
    Node node7=(Node) result7;
    node7.getParentNode().removeChild(node7);
    // Node b13Node = (Node) expression.evaluate(doc, XPathConstants.NODE);
    //b13Node.getParentNode().removeChild(b13Node);
    doc.normalize();
    doc.normalizeDocument();
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    t.setOutputProperty(OutputKeys.METHOD,"xml");
    t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    t.transform(new DOMSource(doc), new StreamResult(System.out));
    catch (Exception e) {
         e.printStackTrace();
    System.out.println(e.getMessage());
    </pre>
    Edited by: user12185243 on Apr 6, 2013 6:38 AM
    Edited by: user12185243 on Apr 6, 2013 6:41 AM
    Edited by: user12185243 on Apr 6, 2013 6:43 AM
    Edited by: user12185243 on Apr 6, 2013 6:45 AM
    Edited by: user12185243 on Apr 6, 2013 9:00 AM

    either this way we can do this
    1)
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    <b> factory.setIgnoringElementContentWhitespace(true); </b>
    DocumentBuilder db = factory.newDocumentBuilder();
    or
    2)
    java.io.StringWriter sw = new java.io.StringWriter();
    StreamResult sr = new StreamResult(sw);
    t.transform(new DOMSource(doc), sr);
    String xml1 = sw.toString().trim();
    <b> xml1=xml1.replaceAll("\\s",""); </b>
    System.out.println(xml1.trim());

  • Mapping tool: mapping child nodes (level2 hierarchy) to bapi wrapper fields

    Hi,
    I'm new to MI7.1. I'll try the demo on help.sap.com. I have following data object EQUIPMENT with node structure in DOE:
    ROOTNODE (attr: EQUIPMENT_ID/ SERIAL_NO)
       child node level 1 DETAILS (attr: SERIAL_NO/TYPE/BRAND/INSTRUCTIONS)
           child node level 2 LOCATION (attr: SERIAL_NO/ADDRESS_LINE1/
    ADDRESS_LINE2/ZIP_CODE/...)
    In backend my bapi wrapper is build using structures:
      TOP: ZSEQUIPMENT (attr: EQUIPMENT_ID/SERIAL_NO)
      010: ZSEQUIPMENT_DET(attr: SERIAL_NO/TYPE/BRAND/INSTRUCTIONS)
      020: ZSLOCATION(attr: SERIAL_NO/ADDRESS_LINE1/...)
    When i want to use mapping tool in middleware for the backend adapter, after mapping the fields, during activation i get the error:
    Referential integrity between node DETAILS and it's parent is not complete.
    Referential integrity between node LOCATION and it's parent is not complete.
    What does that mean? How can I solve this?
    thanks
    Peter

    Solved it myself with explicit key mapping. thanks anyway

  • Parent node showing in schema when child nodes not present

    I had several folks answer my questions on mapping from a flat file to an EDI 835 schema and I am down to just a couple of issues before I finish up. I have a conditional mapping issue that I have to solve before I can map the rest of the document. I am
    mapping three fields in a single non-repeating line in the flat file to a repeating segment in the 835. Basically I need to create a separate AMT_ClaimSupplementalInformation segment for each field in the flat file line. As you can see in the picture
    below I want to create a AMT_ClaimSupplementalInformation segment for CDISCOUNT, CINELIGIBLE and CALLOWED.
    You can see I have quite a bit of conditional logic attached to the three fields, but I have all three connected via a loop to the AMT_ClaimSupplementalInformation parent. I cannot attach the loop to the parent of the three fields because it only appears
    once in the file. And if I leave the loop out the AMT segments get stacked funny, like this:
    <AMT_ClaimSupplementalInformation>
    AMT1
    AMT1
    AMT2
    AMT2
    </AMT_ClaimSupplementalInformation>
    You can see how they should be stacked in the next pic.
    In some cases however, one of those fields may be blank so I will not need to create a AMT_ClaimSupplementalInformation segment for it. I was able to use some conditional mapping ideas you guys gave me using the Not-Equal and Value Mapping functoids, and
    that works great to keep blank child nodes from being created. However, Since I have a loop attached to the AMT_ClaimSupplementalInformation parent node it still creates an empty parent node even when the child nodes are not created. See the empty parent
    node in the pic below.
    Since looping functoids can only be attached to links I don't know how to make the parent node conditional.
    Any suggestions?
    Thanks.

    Boatseller, thanks for the tip. I did end up going the XSLT direction. It's a bit of a hack, but I'm using the following XSLT to eliminate empty nodes :
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="@*|node()">
            <xsl:if test=". != ''">
                <xsl:copy>
                    <xsl:apply-templates select="@*|node()"/>
                </xsl:copy>
            </xsl:if>
        </xsl:template>
    </xsl:stylesheet>
    I created a new map with the 835 schema on each side. I then created an XSLT file and pointed to it in the Custom XSLT Path property. It seems to work well. I call this map right after my FlatFile_To_835 map.
    I was hoping to use the scripting functoid with inline XSLT in the map so that I didn't have to worry about deploying the XSLT file(just another thing to keep up with in the future), but when I compile it I get the following error:
    The "Scripting" functoid has 1 input parameter(s), but 2 parameter(s) are expected.
    I'm wondering if I'm connecting the schemas incorrectly in the map:
    In any case, I'm past the empty nodes issue for now, which was a big roadblock. Now I have to deal with the CAS segments which are, as you said, a real pain. 
    Thanks for all of your input.

Maybe you are looking for