Getting XML child elements

Dear Indesign scripters,
This script is making from all the XML tags ParagraphStyles.
But it refuses to take the child elements. Do I have to use XPath expression? And how?
function main() { 
  var xes, n, doc, ps, xe; 
  if ( !app.documents.length ) return; 
  doc = app.activeDocument;
  xes = doc.xmlElements[0].xmlElements; 
  n = xes.length; 
  while ( n-- ) { 
  xe = xes[n];
  st = doc.paragraphStyles.itemByName (xe.markupTag.name ); 
  !st.isValid && doc.paragraphStyles.add({name:xe.markupTag.name}); 
main();
The XML
<Workbook> 
     <Element_A_01> 
          <Element_A_01></Element_A_01> 
     </Element_A_01> 
     <Element_B_02> 
          <Element_B_02></Element_B_02> 
     </Element_B_02> 
</Workbook>
Greetings from Holland

The code creates two paragraph styles namely Element_A_01 and Element_B_02. These two are created for the immediate child nodes of the Workbook node. Now it seems that you are trying to create pstyles for all the nodes in the XML, which in your case would still be these two as Element_A_01 has a child node that is also named Element_A_01 and the same is the case for Element_B_02.
If i get your point right then you need to create 4 pstyles if all the nodes have different names, but that is not working. For this you will have to recursively traverse each node that you get from the code xes[n].
The code be something like this
function main() {   
  var xes, n, doc, ps, xe;   
  if ( !app.documents.length ) return;   
  doc = app.activeDocument; 
  xes = doc.xmlElements[0].xmlElements; //This gives the immediate child nodes of the Workbook node, hence the length in the next statement is 2  
  n = xes.length;   
  while ( n-- ) {   
  xe = xes[n];   //Here you need to recursively traverse the node xe
  //The no of child elements of xe can be obtained as xe.xmlElements.length
  //First element can be obtained by xe.xmlElements[0]
main();
Hope this solves the issue

Similar Messages

  • How get all child elements from XML

    Hi
    I have one xml i tried to parse that xml using dom parser and i need to get some child elements using java
    <Group>
    <NAME>ABC</NAME>
    <Age>24</AgeC>
    ---------some data here......
    <Group1>
    <group1Category>
    <NAME>ABCTest</NAME>
    <age>27</Age>
    ----Some data here
    <group1subcategory>
    <subcategory>
    <NAME>ABCDEF</NAME>
    <age>28</Age>
    my intention was
    get group name (here ABC) i need all other name value from group1category ,group1 subcategory but pblm that
    my xml contains any number of Group nodes...but only i want name contains ABC
    i wriiten code like this
    DocumentBuilderFactory factory = DocumentBuilderFactory
    .newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(xmlFile);
    NodeList nodeList = document.getElementsByTagName("*");
    for (int i = 0; i < nodeList.getLength(); i++)
    Element element = (Element) nodeList.item(i);
    what is next step i need to do..please help

    964749 wrote:
    Sorry for inconvenience caused..i only asked if any ideas i not ask any body to spent time for me...
    This is simple code developed using xpath..i not know how i proceed further
    public class Demo {
    public static void main(String[] args) {
    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    try {
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    Document dDoc = builder.parse("hello.xml");
    XPath xpath = XPathFactory.newInstance().newXPath();
    javax.xml.xpath.XPathExpression expr = xpath.compile("//Group/NAME");
    Object Name= expr.evaluate(dDoc, XPathConstants.STRING);
    System.out.println(Name);
    } catch (Exception e) {
    e.printStackTrace();
    i need get group name (here ABC) i need all other name value from group1category ,group1 subcategory but pblm that
    ..how i done in XPATH and also do manipulation of remining result...
    i also try with DOM like
    NodeList nodeList = document.getElementsByTagName("GROUP");
    for (int i = 0; i < nodeList.getLength(); i++)
    Element element = (Element) nodeList.item(i);
    if (element.getNodeName().matches("ECUC-MODULE-DEF"))
    String str=((Element) nodeList.item(i)).getElementsByTagName("NAME").item(0).getFirstChild().getNodeValue();
    if(str.equalsIgnoreCase("abc")){
    NodeList children = element.getChildNodes();
    for (int k = 0; k < children.getLength(); k++) {
    Node child = children.item(k);
    System.out.println("children"+children.getLength());
    if (child.getNodeType() != Node.TEXT_NODE) {
    if(child.getNodeName().equalsIgnoreCase("Group1"))
    how iterate for particular ABC name to group1 and subcategoryFew things
    1. Use code tags to format code
    2. Explain the problem statement clearly. Take time to formulate your question. Explain what you expect from your code and what you are getting along with any exceptions that are being thrown

  • Help on creating and deleting xml child elements using Toplink please.

    Hi there,
    I am trying to build a toplink xml demo illustrating toplink acting as the layer between my java code and an xml datasource.
    After pulling my custom schema into toplink and following the steps in http://www.oracle.com/technology/products/ias/toplink/preview/10.1.3dp3/howto/jaxb/index.htm related to
    Click on Mapping Workbench Project...Click on From XML Schema (JAXB)...
    I am able to set up java code which can run get and sets against my xml datasource. However, I want to also be able create and delete elements within the xml data for child elements.
    i.e. in a simple scenario I have a xsd for departments which has an unbounded element of type employee. How does toplink allow me to add and or remove employees in a department on the marshalled xml data source? Only gets and sets for the elements seem accessible.
    In my experience with database schema based toplink demos I have seen methods such as:
    public void setEmployeesCollection(Collection EmployeesCollection) {
         this.employeesCollection = employeesCollection;
    Is this functionality available for xml backended toplink projects?
    cheers
    Nick

    Hi Nick,
    Below I'll give an example of using the generated JAXB object model to remove and add a new node. The available APIs are defined in the JAXB spec. TopLink also supports mapping your own objects to XML, your own objects could contain more convenient APIs for adding or removing collection members
    Example Schema
    The following XML Schema will be used to generate a JAXB model.
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
         elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:element name="department">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="employee" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="employee">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="name" type="xs:string"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>---
    Example Input
    The following document will be used as input. For the purpose of this example this XML document is saved in a file called "employee-data.xml".
    <department>
         <employee>
              <name>Anne</name>
         </employee>
         <employee>
              <name>Bob</name>
         </employee>
    </department>---
    Example Code
    The following code demonstrates how to use the JAXB APIs to remove the object representing the first employee node, and to add a new Employee (with name = "Carol").
    JAXBContext jaxbContext = JAXBContext.newInstance("your_context_path");
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    File file = new File("employee-data.xml");
    Department department = (Department) unmarshaller.unmarshal(file);
    // Remove the first employee in the list
    department.getEmployee().remove(0);
    // Add a new employee
    ObjectFactory objectFactory = new ObjectFactory();
    Employee newEmployee = objectFactory.createEmployee();
    newEmployee.setName("Carol");
    department.getEmployee().add(newEmployee);
    Marshaller marshaller = jaxbContext.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    marshaller.marshal(department, System.out);---
    Example Output
    The following is the result of running the example code.
    <department>
         <employee>
              <name>Bob</name>
         </employee>
         <employee>
              <name>Carol</name>
         </employee>
    </department>

  • Help: to get XML child data in faster way?

    Dear all,
    With the following xml file, how can I use xslt by Java to get any <data> child element's string content. For example, to get "ee ff gg hh" in <Data name="inputs2">ee ff gg hh</Data> [this is in <Info Date="03-05-2003"> branch]?
    I want to get it in a quick way, so I do not want to get it by DOM. The question is what is the best way to get it in Java? Is it possible by SAX combined with XSLT (XPATH) - with Java Code?
    <?xml version="1.0" encoding="UTF-8"?>
    <Customer>
        <Infos>
            <Info Date="03-05-2003" >
                <Inputs name="John">
                    <Data name="inputs1">a b c d</Data>
                    <Data name="inputs2">aa bb cc dd</Data>
                    <Data name="inputsn">an bn cn dn</Data>
                </Inputs>
            </Info>
            <Info Date="03-05-2003" >
                <Inputs name="Mike">
                    <Data name="inputs1">e f g h</Data>
                    <Data name="inputs2">ee ff gg hh</Data>
                    <Data name="inputsn">en fn gn hn</Data>
                </Inputs>
            </Info>
        </Infos>
    </Customer>Thanks
    - John

    The problem is my file could be very large in size,
    and if "load the whole thing into memory", it will
    throw out of memory exception. So the best thing would
    be dynamically load it if possible.
    SAX and XSLT actually can do some help, since whenever
    it finds my requested node, it can stop processing -
    but the problem here is: it has to reparse the XML
    file from the beginning every time to find the
    requested node - a very time-consuming job...
    Any better solution?how about using sax to parse the file, and temporarily insert the records into a DB? You could then use SQL to do your queries.
    parsing/inserting might take awhile; but a properly tuned DB (and the java.sql.statement.addBatch()) will minimize this - probably down to the order of a DOM parse.
    Other solutions:
    - regex and perl/python on the XML file
    - splitting the big XML file into little XML files (one file per <Inputs> tag maybe?) and dealing with an individual node at a time
    - parsing the file as SAX and caching the info you need (i.e. parse it once and cache the values); then look them up afterwards

  • Xpath expression to get depth child element

    Hi
    I wanted to find the depth element (sub isuer) in the hierarchy of 93699V issuer through xpath expression .
    <?xml version="1.0" encoding="UTF-8"?>
    <issuer id="93699V">/>
    <subissuer id="06U99A">
    <subissuer id="52729N">
    <subissuer id="37932J">
    <subissuer id="322995"/>
    <subissuer id="35906P">
    <subissuer id="001575"/> //child of issuer 93699V. since no further child
    <subscriber id="771758"/> //child of issuer 93699V.since no further child
    </subissuer>//end of 37932J
    </subissuer>//end of 52729N
    </subissuer> //end of 06U99A
    </subissuer>
    <subissuer id="06099K">
    <subissuer id="06N99R"/>//child of issuer 93699V.since no further child
    </subissuer>
    <subissuer id="715680"/> ////child of issuer 93699V.since no further child
    </issuer>
    what is the xpath expression to find the depth child of 93699V.i .e o/p is as follows.Since now we have four depth element.
    001575
    771758
    06N99R
    715680
    Please let me know the xpath expression to get depth sub issuer

    Not sure if this helps, there is a section about creating loops in the Workbench ES2 Help at http://help.adobe.com/en_US/livecycle/9.0/workbenchHelp/000187.html#1032146. Another way would be to use a custom component as you suggest but you can do it in Workbench as well.
    Hope that helps..
    ...Gil

  • Creating XML child elements

    I'm generating an XML document. I have reached the third hierarchial level i.e.
    <level_1>
    . <level_2>
    . . <level_3>
    . <level_2>
    . . <level_3>
    . <level_2>
    <level_1>
    Now I am trying to add <level_3> siblings to the existing <level_3> elements and am getting the following exception messages:
    com.ibm.xml.parser.TXDOMException: com.ibm.xml.parser.TXNodeList#insert(): Wrong
    index: 1
    at com.ibm.xml.parser.TXNodeList.insert(TXNodeList.java)
    at com.ibm.xml.parser.Parent.realInsert(Parent.java)
    at com.ibm.xml.parser.Parent.insert(Parent.java)
    at com.ibm.xml.parser.Parent.appendChild(Parent.java)
    at Convertor.processNodeRecursively(Convertor.java:302)
    at Convertor.processNodeRecursively(Convertor.java:320)
    at Convertor.main(Convertor.java:86)
    What does this mean and how do I correct this so I can continue creating elements at <level_3> of the XML doc.

    Hey Jonny99,
    When building a XML document, you have to start at the "lowest" level! If you want an element without any children, it has to be a node. This node you can "append" to an element and so on...
    If it still doesn't work, you could post your code, I'll be happy to take a look at it!!!
    ps I'm working with xml documents too and having some problems with parsing a received string. Please take a look at my topic
    "java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence."
    Greetings Jenny
    [email protected]

  • How to get XML child number

    In AS2 you could use numChildren to get the number of
    children in a given XML file, whats the equivalent in AS3? Ive
    tried using var myNum:Number = myXMLname.numChildren , but when I
    trace it I just get 0.
    Thanks

    You need to call a method these days:
    Say you have an XML Object like the following:
    var myXMLExample:XML =
    <EXAMPLE>
    <ITEM>
    <FRUIT>Apple</FRUIT>
    </ITEM>
    <ITEM>
    <FRUIT>Kiwi</FRUIT>
    </ITEM>
    <ITEM>
    <ANIMAL>Fruitbat</ANIMAL>
    </ITEM>
    </EXAMPLE>
    trace(myXMLExample.ITEM.length()); //since there are three
    ITEMS
    trace(myXMLExample.ITEM.FRUIT.length()); //since there are
    only two ITEMS with FRUIT
    //first trace gives you: 3
    //second trace gives you: 2

  • How to get child elements of element in xml?

    public class Test {
         public static void main(String[] args) {
              Document doc = null;
              System.out.println("!!!");
              try {
                   // TODO if path is 'c:' then make it 'c:/'
                   doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("test.xml");
              } catch (Exception e) {
                   System.out.println("exception");
              Element root = doc.getDocumentElement();
              NodeList dsList = root.getElementsByTagName("GenericDataSource");
              Element e = (Element)dsList.item(0);
             NodeList nl = e.getChildNodes();
             System.out.println(nl.getLength());
             Node n  = nl.item(0);
             Element ee = (Element)n;
    }i want to get child elements. but its throwing exception on typecasting. can u tell me why?

    thanks for the info.
    i got 2 solutions
    SOLUTION 1:
    public class Test {
         public static void main(String[] args) throws Exception {
              Document doc = null;
              System.out.println("!!!");
              try {
                   // TODO if path is 'c:' then make it 'c:/'
                   doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse("test.xml");
              } catch (Exception e) {
                   System.out.println("exception");
              Element root = doc.getDocumentElement();
              NodeList dsList = root.getElementsByTagName("GenericDataSource");
              Element e = (Element)dsList.item(0);
             NodeList nl = e.getChildNodes();
             int count = 0;
             System.out.println(nl.getLength());
             for(int i=0;i<nl.getLength();i++){
                      Node n  = nl.item(i);
                     //System.out.println(n.getClass().getName()); 
                     //System.out.println((Element)n);
                     if(n instanceof Element){ // this checks for node type
                          count++;
                          System.out.println("Element "+(Element)n);
    SOLUTION 2: :
    XPath xpath  = XPathFactory.newInstance().newXPath();
             InputSource inputSource = new InputSource("test.xml");
             NodeList nodes = (NodeList) xpath.evaluate("//GenericDataSource/*", inputSource, XPathConstants.NODESET);
             System.out.println(nodes.getLength());
             System.out.println((Element)nodes.item(9));

  • How to get  xml Element , data and its Childs

    hi,
    I am trying to get entire Element and its childs depending on condition.
    suppose
       if(doc.element.name== "despatch"){
                   // here i want entire despatch element with data and childs and copy into one string like
                   // eg: String dsp = <despatch><name>body1</name> <value>value1<value>
    </despatch>
    <?xml version="1.0">
    <handler>
         <name>header1</name>
         <value>value1</value>
    </handler>
    <despatch>
         <name>body1</name>
         <value>value1<value>
    </despatch>
    <gov>
         <name>env</name>
         <value>value1</value>
    </gov>I managed to get number of elements depending on the Element name but i need to get the entire block.
    nodeList = document.getElementsByTagName("despatch").item(0).getChildNodes();
                        for(int i=0;i<nodeList.getLength();i++){
                             System.out.println("i :"+document.getElementsByTagName("m:Security").item(i));
                        }any kind of help is appreciated.
    Han.
    Edited by: HANRAM on Apr 24, 2008 2:48 AM

    Hi Kartik,
    This one is similar to my question to print and email invoice at same time.  I pass itcpo-tdgetotf = 'X' in order to get otfdata and send email with the attachment of otfdata.
    Now I have data in otfdata, but when I call print_otf function, I clear out itcpo-tdgetotf, and passed
    itcpo-tddest = device_type but I still get error message said 'Handler not valid for open spool request'.
    Can you give me a working example that you have otfdata table and print data from that table.  I also post my question on other thread
    submit report and export to memory
    thanks

  • Org.xml.sax.SAXException:SimpleDeserializer encountered a child element..

    Hi All,
    I created a following program using "GetReportDefintion" method provided by BI Publisher Web Services
    package bip_webservices;
    import com.oracle.xmlns.oxp.service.PublicReportService.ItemData;
    import com.oracle.xmlns.oxp.service.PublicReportService.ReportRequest;
    import com.oracle.xmlns.oxp.service.PublicReportService.ReportResponse;
    import com.oracle.xmlns.oxp.service.PublicReportService.ParamNameValue;
    import com.oracle.xmlns.oxp.service.PublicReportService.ReportDefinition;
    import com.oracle.xmlns.oxp.service.PublicReportService.ScheduleRequest;
    import com.oracle.xmlns.oxp.service.PublicReportService.DeliveryRequest;
    import com.oracle.xmlns.oxp.service.PublicReportService.EMailDeliveryOption;
    import  java.io.FileOutputStream;
    import  java.io.OutputStream;
    import java.net.MalformedURLException;
    import java.rmi.RemoteException;
    import  java.util.Calendar;
    import javax.xml.rpc.ServiceException;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.encoding.XMLType;
    import org.apache.axis.encoding.ser.BeanDeserializerFactory;
    import org.apache.axis.encoding.ser.BeanSerializerFactory;
    import  javax.xml.namespace.QName;
    import  javax.xml.rpc.ParameterMode;
    import  java.net.URL;
    public class BIP_GetReportDefinition {
        public static void main(String[] args) throws ServiceException, MalformedURLException, RemoteException{
         try{
            final String bipEndpoint = "http://localhost:9704/xmlpserver/services/PublicReportService?wsdl";
            final String bipNamespace = "http://xmlns.oracle.com/oxp/service/PublicReportService";
            final String xdofile = "/MyReports/SummaryCustomerReport/SummaryCustomerReport.xdo";
            Service service = new Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(new URL(bipEndpoint));
           System.out.println("BEGIN TESTING getReportDefinition");
            // register the ReportDefinition class
            QName reportDef = new QName(bipNamespace, "ReportDefinition");
            call.registerTypeMapping(ReportDefinition.class, reportDef,
                            BeanSerializerFactory.class, BeanDeserializerFactory.class);
            // register the ParamNameValue class
            QName nmvals = new QName(bipNamespace, "ParamNameValue");
            call.registerTypeMapping(ParamNameValue.class, nmvals, BeanSerializerFactory.class, BeanDeserializerFactory.class);
            call.setOperationName(new QName(bipNamespace, "getReportDefinition"));
            call.addParameter("reportAbsolutePath", XMLType.XSD_STRING, ParameterMode.IN);
            call.addParameter("userID", XMLType.XSD_STRING, ParameterMode.IN);
            call.addParameter("password", XMLType.XSD_STRING, ParameterMode.IN);
            call.setReturnClass(ReportDefinition.class);
            // issue the request
            ReportDefinition reportDefn = (ReportDefinition) call.invoke(
                new Object[] { xdofile, "Administrator", "Administrator"});
            System.out.println("Report Definition Returns with \n Default Output Format = " + reportDefn.getDefaultOutputFormat());
            ParamNameValue params [] = reportDefn.getReportParameterNameValues();
            if (params != null) {
                for (int i = 0; i < params.length; i++) {
                    System.out.print("Parameter " + params.getName() + ":");
    if (params[i].getValues() != null) {
    for (int j = 0; j < params[i].getValues().length; j++)
    System.out.print(" " + params[i].getValues()[j]);
    } else
    System.out.print(" null");
    System.out.println(" - multiple values? " + params[i].isMultiValuesAllowed());
    System.out.println("END TESTING getReportDefinition");
    }catch(Exception e){
    e.printStackTrace();
    I am getting following exception message. Anyone has any ideas what could be the mistake ?
    SEVERE: Exception:
    org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
            at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
            at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
            at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
            at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
            at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
            at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
            at org.apache.axis.client.Call.invoke(Call.java:2467)
            at org.apache.axis.client.Call.invoke(Call.java:2366)
            at org.apache.axis.client.Call.invoke(Call.java:1812)
            at bip_webservices.BIP_GetReportDefinition.main(BIP_GetReportDefinition.java:67)
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
    faultActor:
    faultNode:
    faultDetail:
            {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
            at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
            at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
            at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
            at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
            at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
            at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
            at org.apache.axis.client.Call.invoke(Call.java:2467)
            at org.apache.axis.client.Call.invoke(Call.java:2366)
            at org.apache.axis.client.Call.invoke(Call.java:1812)
            at bip_webservices.BIP_GetReportDefinition.main(BIP_GetReportDefinition.java:67)
            {http://xml.apache.org/axis/}hostname:mildh0228
    org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
            at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
            at org.apache.axis.client.Call.invoke(Call.java:2470)
            at org.apache.axis.client.Call.invoke(Call.java:2366)
            at org.apache.axis.client.Call.invoke(Call.java:1812)
            at bip_webservices.BIP_GetReportDefinition.main(BIP_GetReportDefinition.java:67)
    Caused by: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
            at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
            at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
            at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
            at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
            at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
            at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
            at org.apache.axis.client.Call.invoke(Call.java:2467)
            ... 3 moreThanks for giving this problem a look.
    -Sookie

    Hi Sookie,
    I found the problem is with couple of child parameters are not registered the deserializer. There're couple of additional classes needs to be registerd.
    // register the TemplateLabelValue class
    QName templateval = new QName(bipNamespace, "TemplateFormatLabelValue");
    Class cls = TemplateFormatLabelValue.class;
    call.registerTypeMapping(cls, templateval, BeanSerializerFactory.class, BeanDeserializerFactory.class);
    // register the TemplateLabelValues class
    QName templatevals = new QName(bipNamespace, "TemplateFormatsLabelValues");
    cls = TemplateFormatsLabelValues.class;
    call.registerTypeMapping(cls, templatevals, BeanSerializerFactory.class, BeanDeserializerFactory.class);
    Could you please give it a try?
    Thanks.
    Yang

  • XML element,if not including any attributes and/or child elements then

    XML element in SQLX,if not including any attributes and/or child elements then the tag should not appear, how to achive this?
    ex:Consider for <enumeration> tag where it is having some value.
    <attribute>
    <name>Ethernet Access</name>
    <enumeration>
    <StringValue>Bandwidth</StringValue>
    </enumeration>
    </attribute>
    When <enumeration> tag is not have any Value in this, then output should be as follows.
    <attribute>
    <name>Ethernet Access</name>
    </attribute>
    But what i am getting is
    <attribute>
    <name>Ethernet Access</name>
    </enumeration>
    </attribute>
    Please suggest me the solution for this.
    I tried , but when xmlelement() is not having data it will display empty tag ie </enumeration>, If xmlforest() are null it wont show tag, But i have to use xmlelement only. how can that be achived using xmlelement .

    Use a SQL case - when - else end construct to only execute the xmlelement if data is present. The SQL/XML standard is very clear, xmlElement will generate an empty element if no data is present. xmlforest will not.

  • Getting XML Elements

    I am returning some XML elements(for example Figure elements) using Xpath in Javascript, which is assingned to one object in VB.net. There is no problem when i am getting(those elements) from CS5.5 Document but while i am getting from CS3 document it shows COM Object error. My code is as follows.
            SerializedObject.IApplication = CreateObject("InDesign.Application.CS3")
            Dim a As Object = SerializedObject.IApplication.DoScript("C:\Documents and Settings\pg4007\Desktop\scripts\Find_Float_Element.jsx", InDesign.idScriptLanguage.idJavascript, )
    it shows,
    Error HRESULT E_FAIL has been returned from a call to a COM component.
    Plz help me.

    The code creates two paragraph styles namely Element_A_01 and Element_B_02. These two are created for the immediate child nodes of the Workbook node. Now it seems that you are trying to create pstyles for all the nodes in the XML, which in your case would still be these two as Element_A_01 has a child node that is also named Element_A_01 and the same is the case for Element_B_02.
    If i get your point right then you need to create 4 pstyles if all the nodes have different names, but that is not working. For this you will have to recursively traverse each node that you get from the code xes[n].
    The code be something like this
    function main() {   
      var xes, n, doc, ps, xe;   
      if ( !app.documents.length ) return;   
      doc = app.activeDocument; 
      xes = doc.xmlElements[0].xmlElements; //This gives the immediate child nodes of the Workbook node, hence the length in the next statement is 2  
      n = xes.length;   
      while ( n-- ) {   
      xe = xes[n];   //Here you need to recursively traverse the node xe
      //The no of child elements of xe can be obtained as xe.xmlElements.length
      //First element can be obtained by xe.xmlElements[0]
    main();
    Hope this solves the issue

  • Error While trying to Get XML element(tag) Values

    We are trying to get XML element (TAG) value from the XML pay load.
    Example.
    Getting XML String from a web service and then converting into XML payload.
    ora:parseEscapedXML(bpws:getVariableData('signOn_Out','signOnReturn'))
    From this XML payload we are trying to get an element (Tag) value.
    We are getting following error
    Error in evaluate <from> expression at line "130". The result is empty for the XPath expression : "/client:TririgaProcessResponse/client:User/client:LastName".
    oracle.xml.parser.v2.XMLElement@118dc2a
    {http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.
    - <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    - <part name="summary">
    <summary>
    empty variable/expression result.
    xpath variable/expression expression "/client:TririgaProcessResponse/client:User/client:LastName" is empty at line 130, when attempting reading/copying it.
    Please make sure the variable/expression result "/client:TririgaProcessResponse/client:User/client:LastName" is not empty.
    </summary>
    </part>
    </selectionFailure>
    Here are signOnReturn and XML Payload XSD's
    <schema attributeFormDefault="unqualified"
         elementFormDefault="qualified"
         targetNamespace="http://xmlns.oracle.com/Web1"
         xmlns="http://www.w3.org/2001/XMLSchema">
         <element name="Web1ProcessRequest">
              <complexType>
                   <sequence>
                        <element name="userName" type="string"/>
    <element name="password" type="string"/>
                   </sequence>
              </complexType>
         </element>
         <element name="Web1ProcessResponse">
              <complexType>
                   <sequence>
                        <element name="result" type="string"/>
                   </sequence>
              </complexType>
         </element>
    </schema>
    <?xml version="1.0" encoding="windows-1252" ?>
    <schema attributeFormDefault="unqualified"
         elementFormDefault="qualified"
         targetNamespace="http://xmlns.oracle.com/Web"
         xmlns="http://www.w3.org/2001/XMLSchema">
         <element name="TProcessResponse">
              <complexType>
                   <sequence>
                        <element name="result" type="string"/>
    <element name="User">
    <complexType>
                   <sequence>
                        <element name="Id" type="string"/>
    <element name="CompanyId" type="string"/>
    <element name="SecurityToken" type="string"/>
    <element name="FirstName" type="string"/>
    <element name="LastName" type="string"/>
    </sequence>
    </complexType>
    </element>
                   </sequence>
              </complexType>
         </element>
    </schema>

    I am sure and can see the data in audit trail.
    [2006/12/12 09:17:36]
    Updated variable "signOn_Output"
    - <signOn_Output>
    - <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
    - <WebMethodsProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
    <Result xmlns="">
    Success
    </Result>
    - <User xmlns="">
    <Id>
    2694069
    </Id>
    <CompanyId>
    208133
    </CompanyId>
    <SecurityToken>
    1165936654605
    </SecurityToken>
    <FirstName>
    Jagan
    </FirstName>
    <LastName>
    Rao
    </LastName>
    </User>
    </WebMethodsProcessResponse>
    </part>
    </signOn_Output>
    Copy details to clipboard
    [2006/12/12 09:17:36]
    Updated variable "tririga"
    - <tririga>
    - <TririgaProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
    <Result xmlns="">
    Success
    </Result>
    - <User xmlns="">
    <Id>
    2694069
    </Id>
    <CompanyId>
    208133
    </CompanyId>
    <SecurityToken>
    1165936654605
    </SecurityToken>
    <FirstName>
    Jagan
    </FirstName>
    <LastName>
    Rao
    </LastName>
    </User>
    </TririgaProcessResponse>
    </tririga>
    Copy details to clipboard
    [2006/12/12 09:17:36]
    Updated variable "Variable_2"
    - <Variable_2>
    - <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
    - <TririgaProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
    <Result xmlns="">
    Success
    </Result>
    - <User xmlns="">
    <Id>
    2694069
    </Id>
    <CompanyId>
    208133
    </CompanyId>
    <SecurityToken>
    1165936654605
    </SecurityToken>
    <FirstName>
    Jagan
    </FirstName>
    <LastName>
    Rao
    </LastName>
    </User>
    </TririgaProcessResponse>
    </part>
    </Variable_2>
    Copy details to clipboard
    [2006/12/12 09:17:36]
    Error in evaluate <from> expression at line "130". The result is empty for the XPath expression : "/client:TririgaProcessResponse/client:User/client:LastName".
    oracle.xml.parser.v2.XMLElement@1c8768e
    Copy details to clipboard
    [2006/12/12 09:17:36]
    "{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.
    - <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    - <part name="summary">
    <summary>
    empty variable/expression result.
    xpath variable/expression expression "/client:TririgaProcessResponse/client:User/client:LastName" is empty at line 130, when attempting reading/copying it.
    Please make sure the variable/expression result "/client:TririgaProcessResponse/client:User/client:LastName" is not empty.
    </summary>
    </part>
    </selectionFailure>
    Copy details to clipboard

  • How to get the second element in XML Response with same name

    Hi All,
    I am struck at this point, I have written a sample HTTP client which sends a request to the HTTP Server. In response to the request made the HTTP Server gives response in the XML format. eg: -
    <?xml version="1.0"?>
    <parent>
    <node1> Value1 </node1>
    <node1> Value2 </node1>
    <node2> Value3 </node2>
    </parent>
    In the HTTP Client I am getting the value of node1 using the following statement: -
    if (node instanceof Element && "node1".equals(((Element)node).getName()) )
    String node1 = node.getStringValue();
    System.out.println("Product Code:"+node1);
    This is always returning the first node1 value i.e. <node1> Value1 </node1>.
    The requirement is, I also need to get the <node1> Value2 </node1> value also. So can anyone tell me hw can I get the <node1> Value2 </node1> value. please tell me the piece of code that I should add to get the <node1> Value2 </node1>.
    My Mode is something like this: -
    try
                   Document document = (Document)DocumentHelper.parseText(response);
                   List<Node> transactionNodeList = document.selectNodes( "//parent" );
                   for(Node singleNode:transactionNodeList)
                        for(int i=0,j=0;i< ((Element)singleNode).nodeCount();i++ )
                             Node node = ((Element)singleNode).node(i);
                             if (node instanceof Element && "node1".equals(((Element)node).getName()) )
    node1= node.getStringValue();
    System.out.println("Air Way Bill Number:"+node1);
    if (node instanceof Element && "node1".equals(((Element)node).getName()) )
    node1= node.getStringValue();
    System.out.println("Product Code:"+node1);
    Thanks in Advance

    DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
         DocumentBuilder db=factory.newDocumentBuilder();
         Document doc=db.parse(new File(ur xml file"));
         Element root=doc.getDocumentElement();
         System.out.println("root "+root.getNodeName());

  • Child element of target node in message mapping getting suppressed

    Hello All,
                      I am having  mapping where i am trying  to generate the target node based on some condition of the source structure ,this is working fine ,I am able to generate the target node once the condition gets satisfied ,but the problem is one of the  child elements of the same node is not getting populated,its getting suppressed,i have some condition for the same
    I checked  the  queues its showing value as
    SUPPRESS
    Value
    Value ( in grey )
    But still element is not getting generated..
    I have added a condition used at the node function and apart from other condition of element..
    If some body have the solution for the same,please help me out
    Thanks in advance
    Rajesh

    Hi Rajesh,
    The Error is mostly cause of that the node and your child are in same context.
    You got to remember that the parent node creates the context, and then the child element puts the value in it.
    Try putting your child element to a higher context then mapwithdefault for your supress and then removecontext.
    This Issue, you got to work it out with the node functions,
    I had the same kind of issue in my mapping, it was rectified with the help of node functions as mapwithdefault, removecontext.
    Further unless one sees the mapping of your issue it is a bit difficult to imagine it and answer it.
    For more clarifications please give the full hierarchy, and the condition. As of now try with the node functions.
    Thanks
    Ashmi

Maybe you are looking for