scruffycoder86
scruffycoder86

Reputation: 549

Namespace prefix 'salesValue' is not defined in Flowgear

I have decided to use an XFormat Node to grab my JSON POSTFIELDS from an API invoke using PHP. Below is the result of the XML data transformed from the JSON string to a XMLDocument:

<root>
  <salesValue>5000</salesValue>
  <authorId>2</authorId>
</root>

Reading from https://developers.flowgear.net/kb/Node:XPath_Match I came up with the following xpaths to grab those values am interested in and inject them on my SQL Query:

I have chosen XML as my escaping value for that property not sure which one it should be. The error I am getting is:

(XFormat 1.0.0.1): Namespace prefix 'salesValue' is not defined.

I guesss the issue is with how I have formatted my xpath in an attempt to grab those values. The SQL Query in the expression property of my XFormat node is shown below:

SELECT `Book`.`id` , `Book`.`name` , `Book`.`isbn` , `Book`.`quantity_in_stock` , `Book`.`price`      , (`Book`.`quantity_in_stock` * `Book`.`price`) AS `sales`, 
concat(`Author`.`name`, ' ', `Author`.`surname`) AS `author`  FROM `books` AS `Book` LEFT JOIN     authors AS `Author` ON ( `Book`.`author_id` = `Author`.`id` ) 
WHERE  (`Book`.`quantity_in_stock` * `Book`.`price`) > {salesValue} AND `Book`.`author_id` = "   {authorId}"

Should I have these values injected in that query I will be able to move forward. Below is the script I use to invoke the WORKFLOW via an API:

              try{
    $results = invokeFlowgear("https://domain.flowgear.io/authorbooksaleslist", "login", "passwrd", 30,
       array(
        'salesValue' => 5000.00,
        'authorId' => 2
     ));

    var_dump($results);


          }catch(Exception $exc){ print $exc->getMessage(); }

Thank you in advance...

Upvotes: 0

Views: 280

Answers (2)

Skillie
Skillie

Reputation: 151

The values in your custom properties should only contain the xpaths, and the names of the custom properties should match your placeholders in the Expression.

You can find the documentation at https://developers.flowgear.net/kb/Node:XFormat#Examples

Upvotes: 1

ThW
ThW

Reputation: 19512

The address of an element in Xpath can have up to three parts:

  1. A local name or * (for all) elements: foo, html - This is mandatory
  2. A namepspace prefix/alias: n1:foo, xhtml:html - No prefix, means no namespace
  3. An axis defining the initial list of elements: children::foo, following-sibling::xhtml:div- default is children

Your XML has no namespaces. It is just wellformed. So providing the 'salesValue' or 'authorId' as namepace prefix is wrong.

Addressing the values from the document root:

  • /root/salesValue
  • /root/authorId

I think the test1: in the example the linked page is just to provide an identifier to the Xpath expression and not a part of it.

Upvotes: 0

Related Questions