Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Use token or variable in Get data from XML Loop XPath

  1. #1
    Join Date
    Dec 2015
    Posts
    3

    Default Use token or variable in Get data from XML Loop XPath

    Hi

    I am trying to create a transformation that calls a web service and places the returned data into a table. The repeating node in the web service xml has a variable node name, I don't know what it might be called. I created a Modified Java Script Value step that reads the xml and places the node name into an output field.

    In my Get data from XML step I tried to use both fields and variables in the Loop XPath property to specify the node name but can't seem to get either to work.

    My question is simply how do I specify a Loop XPath parameter the has a variable value?

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    So your document root element goes by the name "*" ?
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Dec 2015
    Posts
    3

    Default

    No but the repeating node that contains the data I am interested in has a variable name, I know where to find it in the document but don't what it might be called. That is why I have a java script step that parses the document to discover the node name. I am trying to figure out a way to store that name in a field or variable and then use it in the Loop Xpath parameter in the Get data from XML step.

  4. #4
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    I thought you were processing documents with different root elements, but after reading again I see it's the repeating element itself you want to access anonymously.

    If no other element types occur as siblings you can still access the repeating element anonymously, e.g. /root/*
    Otherwise you must use 2 transformations, one to determine the element name, storing it in a variable (setVariable), another one to access the variable in your Loop XPath expression e.g. /root/${ELEMENT_NAME}
    Reason is that the variables of a transformation are copied from the caller (e.g. a job) during initialization of the transformation and thus can't be manipulated from within the transformation.
    So long, and thanks for all the fish.

  5. #5
    Join Date
    Dec 2015
    Posts
    3

    Default

    Quote Originally Posted by marabu View Post
    I thought you were processing documents with different root elements, but after reading again I see it's the repeating element itself you want to access anonymously.

    If no other element types occur as siblings you can still access the repeating element anonymously, e.g. /root/*
    Otherwise you must use 2 transformations, one to determine the element name, storing it in a variable (setVariable), another one to access the variable in your Loop XPath expression e.g. /root/${ELEMENT_NAME}
    Reason is that the variables of a transformation are copied from the caller (e.g. a job) during initialization of the transformation and thus can't be manipulated from within the transformation.
    I see I guess that makes sense, it would be nice though if you could use an input field in the Loop XPath.

    Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.