How to get Currency and Term Names in Netsuite Search or Save Search - netsuite

I am working on a solution on workato automation tool where I have to search newly created or updated invoices from NetSuite and get it synced to salesforce.
As per this requirement I am performing a netsuite search operation in workato, which internally using "TransactionSearchAdvanced" in netsuite.
The response I am getting is having internal ids of currency and payment terms not the name. As show below.
My requirement is to get currency name e.g "UDS" and payment term name e.g. "Net 45".
I had developed a similar solution using mulesoft and in mulesot currenyName and termName meta data were automatically coming to select but in workato it is not coming.
Is there any special join I can use in netsuite save search? I have tried save search as well but counldnt find the relation between transaction and terms.
Below are the requests I can see in the netsutie web service log when I execute the search operation in workato.
And this is the xml requiest this connector is making to netsutie.
<env:Envelope xmlns:transactionsInventoryTypes="urn:types.inventory_2020_2.transactions.webservices.netsuite.com" xmlns:setupCustomization="urn:customization_2020_2.setup.webservices.netsuite.com" xmlns:listsSupplychainTypes="urn:types.supplychain_2020_2.lists.webservices.netsuite.com" xmlns:transactionsGeneral="urn:general_2020_2.transactions.webservices.netsuite.com" xmlns:platformCore="urn:core_2020_2.platform.webservices.netsuite.com" xmlns:transactionsDemandplanningTypes="urn:types.demandplanning_2020_2.transactions.webservices.netsuite.com" xmlns:transactionsDemandPlanning="urn:demandplanning_2020_2.transactions.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:generalCommunicationTypes="urn:types.communication_2020_2.general.webservices.netsuite.com" xmlns:listsRelationshipsTypes="urn:types.relationships_2020_2.lists.webservices.netsuite.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:platformCommon="urn:common_2020_2.platform.webservices.netsuite.com" xmlns:generalCommunication="urn:communication_2020_2.general.webservices.netsuite.com" xmlns:transactionsInventory="urn:inventory_2020_2.transactions.webservices.netsuite.com" xmlns:listsWebsite="urn:website_2020_2.lists.webservices.netsuite.com" xmlns:listsSupplyChain="urn:supplychain_2020_2.lists.webservices.netsuite.com" xmlns:listsAccountingTypes="urn:types.accounting_2020_2.lists.webservices.netsuite.com" xmlns:platformMsgs="urn:messages_2020_2.platform.webservices.netsuite.com" xmlns:listsEmployees="urn:employees_2020_2.lists.webservices.netsuite.com" xmlns:listsMarketing="urn:marketing_2020_2.lists.webservices.netsuite.com" xmlns:transactionsCustomers="urn:customers_2020_2.transactions.webservices.netsuite.com" xmlns:activitiesSchedulingTypes="urn:types.scheduling_2020_2.activities.webservices.netsuite.com" xmlns:transactionsSales="urn:sales_2020_2.transactions.webservices.netsuite.com" xmlns:listsWebsiteTypes="urn:types.website_2020_2.lists.webservices.netsuite.com" xmlns:listsRelationships="urn:relationships_2020_2.lists.webservices.netsuite.com" xmlns:transactionsBank="urn:bank_2020_2.transactions.webservices.netsuite.com" xmlns:listsMarketingTypes="urn:types.marketing_2020_2.lists.webservices.netsuite.com" xmlns:listsSupportTypes="urn:types.support_2020_2.lists.webservices.netsuite.com" xmlns:platformFaults="urn:faults_2020_2.platform.webservices.netsuite.com" xmlns:documentsFileCabinet="urn:filecabinet_2020_2.documents.webservices.netsuite.com" xmlns:transactionsFinancial="urn:financial_2020_2.transactions.webservices.netsuite.com" xmlns:listsSupport="urn:support_2020_2.lists.webservices.netsuite.com" xmlns:setupCustomizationTypes="urn:types.customization_2020_2.setup.webservices.netsuite.com" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:transactionsEmployees="urn:employees_2020_2.transactions.webservices.netsuite.com" xmlns:activitiesScheduling="urn:scheduling_2020_2.activities.webservices.netsuite.com" xmlns:documentsFilecabinetTypes="urn:types.filecabinet_2020_2.documents.webservices.netsuite.com" xmlns:transactionsSalesTypes="urn:types.sales_2020_2.transactions.webservices.netsuite.com" xmlns:listsAccounting="urn:accounting_2020_2.lists.webservices.netsuite.com" xmlns:transactionsPurchases="urn:purchases_2020_2.transactions.webservices.netsuite.com" xmlns:listsEmployeesTypes="urn:types.employees_2020_2.lists.webservices.netsuite.com">
<env:Header>
<platformCore:tokenPassport>
<platformCore:account>******</platformCore:account>
<platformCore:consumerKey>****************************************************************</platformCore:consumerKey>
<platformCore:token>****************************************************************</platformCore:token>
<platformCore:nonce>*****</platformCore:nonce>
<platformCore:timestamp>******</platformCore:timestamp>
<platformCore:signature algorithm="HMAC_SHA256">*********************************************</platformCore:signature>
</platformCore:tokenPassport>
<platformMsgs:searchPreferences>
<platformMsgs:pageSize>200</platformMsgs:pageSize>
<platformMsgs:bodyFieldsOnly>false</platformMsgs:bodyFieldsOnly>
</platformMsgs:searchPreferences>
</env:Header>
<env:Body>
<platformMsgs:search>
<platformMsgs:searchRecord xsi:type="transactionsSales:TransactionSearchAdvanced">
<transactionsSales:criteria>
<transactionsSales:basic>
<platformCommon:lastModifiedDate operator="after">
<platformCore:searchValue>2022-08-01T03:42:08+00:00</platformCore:searchValue>
</platformCommon:lastModifiedDate>
<platformCommon:mainLine>
<platformCore:searchValue>true</platformCore:searchValue>
</platformCommon:mainLine>
<platformCommon:type operator="anyOf">
<platformCore:searchValue>_invoice</platformCore:searchValue>
</platformCommon:type>
</transactionsSales:basic>
</transactionsSales:criteria>
<transactionsSales:columns>
<transactionsSales:basic>
<platformCommon:amountRemaining>nil</platformCommon:amountRemaining>
<platformCommon:tranDate>nil</platformCommon:tranDate>
<platformCommon:dueDate>nil</platformCommon:dueDate>
<platformCommon:status>nil</platformCommon:status>
<platformCommon:recordType>nil</platformCommon:recordType>
<platformCommon:total>nil</platformCommon:total>
<platformCommon:terms>nil</platformCommon:terms>
<platformCommon:otherRefNum>nil</platformCommon:otherRefNum>
<platformCommon:tranId>nil</platformCommon:tranId>
<platformCommon:internalId>nil</platformCommon:internalId>
<platformCommon:salesRep>nil</platformCommon:salesRep>
<platformCommon:currency>nil</platformCommon:currency>
<platformCommon:exchangeRate>nil</platformCommon:exchangeRate>
<platformCommon:lastModifiedDate>nil</platformCommon:lastModifiedDate>
<platformCommon:customFieldList>
<platformCore:customField scriptId="custbody_sfdc_customer_id" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custbody_collections_notes" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custbody_sfdc_opp_int_id" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custbody_customer_success_manager" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_expense_url" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_far_trn_relatedasset" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_2663_lastname" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_2663_firstname" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_2663_companyname" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_2663_isperson" xsi:type="platformCore:SearchColumnBooleanCustomField"/>
<platformCore:customField scriptId="custcol_2663_eft_file_format" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_9997_dd_file_format" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_nsts_gaw_col_approver" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_tran_no" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_opp_type" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_po_line_id" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_coursera_term_in_days_so" xsi:type="platformCore:SearchColumnLongCustomField"/>
<platformCore:customField scriptId="custcol_coursera_term_end_date" xsi:type="platformCore:SearchColumnDateCustomField"/>
<platformCore:customField scriptId="custcol_coursera_term_start_date" xsi:type="platformCore:SearchColumnDateCustomField"/>
<platformCore:customField scriptId="custcol_coursera_rev_rec_rule_so" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_is_a_mod" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_system_contract" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_content_fee_unit_price" xsi:type="platformCore:SearchColumnDoubleCustomField"/>
<platformCore:customField scriptId="custcol_degree_item" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_degree_term" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_9572_eft_entitybank_sub" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_9572_eft_entitybank_format" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_9572_dd_entitybank_format" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_9572_dd_entitybank_sub" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_9572_dd_file_format" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_9572_cr_entitybank_format" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_9572_cr_entitybank_sub" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol_9572_custref_file_format" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol1" xsi:type="platformCore:SearchColumnBooleanCustomField"/>
<platformCore:customField scriptId="custcol2" xsi:type="platformCore:SearchColumnDateCustomField"/>
<platformCore:customField scriptId="custcol3" xsi:type="platformCore:SearchColumnBooleanCustomField"/>
<platformCore:customField scriptId="custcol4" xsi:type="platformCore:SearchColumnBooleanCustomField"/>
<platformCore:customField scriptId="custcol_ibm_project" xsi:type="platformCore:SearchColumnSelectCustomField"/>
<platformCore:customField scriptId="custcol13" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_15529_eft_enabled" xsi:type="platformCore:SearchColumnBooleanCustomField"/>
<platformCore:customField scriptId="custcol_coupa_er_lineid" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_coupa_er_desc" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_coupa_er_reason" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_coupa_po_url" xsi:type="platformCore:SearchColumnStringCustomField"/>
<platformCore:customField scriptId="custcol_sfdc_line_id" xsi:type="platformCore:SearchColumnLongCustomField"/>
<platformCore:customField scriptId="custcol_cseg1" xsi:type="platformCore:SearchColumnSelectCustomField"/>
</platformCommon:customFieldList>
</transactionsSales:basic>
</transactionsSales:columns>
</platformMsgs:searchRecord>
</platformMsgs:search>
</env:Body>
</env:Envelope>

Related

add a numeric value to an element using xslt-3

if i have an xml file like below:
<?xml version="1.0" encoding="UTF-8"?>
<CATALOG>
<CD ID="1">
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD ID="2">
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>31</PRICE>
<YEAR>1988</YEAR>
</CD>
</CATALOG>
how i could add to each price element the value of 1000, so there is a sum like current value + 1000, using xslt-3?
Output:
<?xml version="1.0" encoding="UTF-8"?>
<CATALOG>
<CD ID="1001">
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>1010</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD ID="1002">
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>1031</PRICE>
<YEAR>1988</YEAR>
</CD>
</CATALOG>
If you write a template for the PRICE elements and handle the rest by xsl:mode on-no-match="shallow-copy" (https://www.w3.org/TR/xslt-30/#built-in-templates-shallow-copy) you get
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.0">
<xsl:param name="to-be-added" as="xs:decimal" select="1000"/>
<xsl:mode on-no-match="shallow-copy"/>
<xsl:template match="PRICE">
<xsl:copy>
<xsl:value-of select=". + $to-be-added"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
https://xsltfiddle.liberty-development.net/6qM2e2j

Preparing SOAP request with WS-Security, RSA Encryption in node.js

I am trying to create an http client from wsdl and send an encrypted request.
However, I have tried most of encryption-Security packages in npm(soap, soap-x509-http, xml-crypto etc.) to achieve my goal but I couldn't send a correct request.
You can see the requirements and a sample request below.
Thanks in advance.
Encryption should be performed using the following algorithms:
a. Key Encryption Algorithm: rsa-1_5
b. Symmetric Encryption Algorithm: #aes128-cbc
c. Encription Canonicalization: xml-exc-c14n
d. Token reference type: keyIdentifier (SKI)
Signature should be performed using the following algorithms:
a. Signature Algorithm: rsa-sha1
b. CanonicalizationMethod Algorithm: xml-exc-c14n
SOAP message could contain Timestamp
Sample Request(cipher values are shortened)
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" env:mustUnderstand="1">
<wsu:Timestamp wsu:Id="timestamp">
<wsu:Created>2017-01-25T10:53:55.572Z</wsu:Created>
<wsu:Expires>2017-01-25T10:58:55.572Z</wsu:Expires>
</wsu:Timestamp>
<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="token-47-1485341635575-1612376233">MIICXjCCAcegAwIBQ==</wsse:BinarySecurityToken>
<xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
<xenc:EncryptionMethod xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<wsse:SecurityTokenReference wsu:Id="reference-50-1485341635576-76405248">
<wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary7f9" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier">MZBUluEDgIrFJrntxdBEI9Cr2A0=</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
<xenc:CipherData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
<xenc:CipherValue xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">m5xNzosqhCIll4rMOH97zwKNprCC15w0LDta+NL81yIcPuLftJNZeI/RiPmJY7d3y2bdMV5Y=</xenc:CipherValue>
</xenc:CipherData>
<xenc:ReferenceList xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
<xenc:DataReference xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" URI="#encrypted-49-1485341635575-737511276"/>
</xenc:ReferenceList>
</xenc:EncryptedKey>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:CanonicalizationMethod xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference xmlns:ds="http://www.w3.org/2000/09/xmldsig#" URI="#element-46-1485341635572-1313338421">
<ds:Transforms xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Transform xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">koftV3puKxIgrkVHHxwSJYxsUhA=</ds:DigestValue>
</ds:Reference>
<ds:Reference xmlns:ds="http://www.w3.org/2000/09/xmldsig#" URI="#timestamp">
<ds:Transforms xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Transform xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod xmlns:ds="http://www.4dbw3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">Q0nZM95JuHF2nveehBU6wjUsoY4=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">BvlJMHJNrfI=</ds:SignatureValue>
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<wsse:SecurityTokenReference wsu:Id="reference-48-1485341635575-111206538">
<wsse:Reference URI="#token-47-1485341635575-1612376233" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
</wsse:Security>
</env:Header>
<env:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="element-46-1485341635572-1313338421">
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="encrypted-49-1485341635575-737511276" Type="http://www.w3.org/2001/04/xmlenc#Content">
<xenc:EncryptionMethod xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
<xenc:CipherData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
<xenc:CipherValue xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">XoH4ROAG+6v0A28z1YeGeUfl4Im1q/jEJO+uDtAejU=13</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
</env:Body>
</env:Envelope>

Groovy GPath find all children nodes by condition

Given this XML
<?xml version="1.0" encoding="UTF-8"?>
<data>
<level0 id="1" t="0" l0id="0">
<level1 id="lev1id01" att1="2015-05-12" val="12" status="0" year="2015" month="05" />
<level1 id="lev1id02" att1="2015-06-13" val="13" status="0" year="2015" month="07" />
<level1 id="lev1id03" att1="2015-07-10" val="13" status="0" year="2015" month="04" />
</level0>
<level0 id="2" t="1" l0id="2">
<level1 id="lev1id21" att1="2015-05-12" val="121" status="0" year="2015" month="05" />
<level1 id="lev1id22" att1="2015-06-13" val="132" status="0" year="2015" month="06" />
<level1 id="lev1id23" att1="2015-07-11" val="113" status="0" year="2015" month="08" />
<level1 id="lev1id24" att1="2015-07-11" val="114" status="0" year="2015" month="07" />
</level0>
</data>
I need to find all level1 nodes (one per each level0 node) sorted by att1, then year and month values.
For this example I expect to get nodes:
level1[#id="lev1id03"]
level1[#id="lev1id23"] -- because it has month = 08 which is maximum
I suppose I have to use something like this:
new XmlSlurper().parseText(xml).level0.level1.findAll {level1 ->
/* some closure */
}
Unfortunately I'm not an Groovy/GPath expert so I'm looking for a Groovish way to do it.
Thanks.

Groovy find nodes using gpath with certian child count and expression

Suppose I have an XML:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<level0 id="1" t="0">
<level1 id="lev1id01" att1="2015-05-12" val="12" status="0"/>
<level1 id="lev1id02" att1="2015-06-13" val="13" status="0"/>
<level1 id="lev1id03" att1="2015-07-10" val="13" status="0"/>
</level0>
<level0 id="2" t="0">
<level1 id="lev1id11" att1="2015-05-12" val="121" status="0"/>
<level1 id="lev1id12" att1="2015-06-13" val="132" status="0"/>
<level1 id="lev1id13" att1="2015-07-11" val="113" status="0"/>
</level0>
<level0 id="2" t="1">
<level1 id="lev1id21" att1="2015-05-12" val="121" status="0"/>
<level1 id="lev1id22" att1="2015-06-13" val="132" status="0"/>
<level1 id="lev1id23" att1="2015-07-11" val="113" status="0"/>
<level1 id="lev1id23" att1="2015-07-11" val="113" status="0"/>
</level0>
</data>
I want to get all level0 nodes (using GPath) which are:
If level0/#t="0" then select this node (level0) only if all its level1 children has #status="0"
If level0/#t!="0" then select this node (level0) only if the last level1 child has #status="0". When I say last I mean the level1 node with maximum value in #att1 (assuming #att1 contains date in yyyy-mm-dd format).
With XPath I would use functions like max() and count(), but I can't get how it could be done using GPath.
Thanks
The max() and count() functions defined by Groovy on Iterable can be used within GPath expressions in place of their XPath equivalents.
// This closure is for level0[t=0] elements.
// It selects the level0 if the count of its level1[status=0] children is 0.
def t0Select = { level0 ->
level0.level1.count { level1 -> level1.#status != '0' } == 0
}
// This closure is for level1[t=1] elements.
// It selects the level0 if its level1 element with the maximum date has a status of "0"
def t1Select = { level0 ->
level0.level1.max { level1 -> Date.parse('yyyy-MM-dd', level1.#att1.toString()) }?.#status == '0'
}
// Parse the XML and delegate to the appropriate closure above as per the t attribute
def selected = new XmlSlurper().parseText(xml).level0.findAll { level0 ->
level0.#t == '0' ? t0Select(level0) : t1Select(level0)
}

AnchorPane Constraints don't work

In application one FXML is loaded into tha AnchorPane of the other FXML. The problem is that the AnchorPane Constraints (exactly Bottom one) of ListView don't want to work during resizing.
The code of the file which is loaded:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="-1.0" prefWidth="-1.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2">
<children>
<HBox cache="true" cacheHint="SPEED" fillHeight="true" minHeight="-1.0" prefHeight="-1.0" prefWidth="1280.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<TabPane id="navPane" cache="true" cacheHint="SPEED" maxWidth="-1.0" minHeight="-1.0" minWidth="-1.0" prefHeight="-1.0" prefWidth="420.0" rotateGraphic="false" side="LEFT" tabClosingPolicy="UNAVAILABLE" tabMaxHeight="1.7976931348623157E308" tabMinHeight="30.0" HBox.hgrow="NEVER">
<tabs>
<Tab closable="true" text="Untitled Tab 1">
<content>
<AnchorPane id="AnchorPane" fx:id="homePane" cache="true" cacheHint="SPEED" maxHeight="-1.0" maxWidth="-1.0" minHeight="-1.0" minWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" style="-fx-background-color: red;">
<children>
<StackPane id="navPaneHeaderPane" cache="true" cacheHint="SPEED" prefHeight="35.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<AnchorPane id="navPaneHeaderPane" cache="true" cacheHint="SPEED" prefHeight="200.0" prefWidth="200.0" style="" />
<Label id="navPaneHeaderString" cache="true" cacheHint="SPEED" text="Label" StackPane.alignment="CENTER" />
</children>
</StackPane>
<TextField cache="true" cacheHint="SPEED" prefHeight="30.0" prefWidth="294.0" AnchorPane.leftAnchor="28.0" AnchorPane.rightAnchor="28.0" AnchorPane.topAnchor="55.0" />
<Separator cache="true" cacheHint="SPEED" prefWidth="200.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="100.0" />
<ListView fx:id="listView" cache="true" cacheHint="SPEED" minHeight="-1.0" minWidth="-1.0" pickOnBounds="true" prefHeight="-1.0" prefWidth="-1.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="120.0" />
</children>
</AnchorPane>
</content>
</Tab>
<Tab text="Untitled Tab 2">
<content>
<AnchorPane id="Content" cache="true" cacheHint="SPEED" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
</tabs>
</TabPane>
<AnchorPane cache="true" cacheHint="SPEED" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS">
<children>
<TableView cache="true" cacheHint="SPEED" prefHeight="700.0" prefWidth="860.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="0.0">
<columns>
<TableColumn prefWidth="75.0" text="Column X" />
<TableColumn prefWidth="75.0" text="Column X" />
</columns>
</TableView>
</children>
</AnchorPane>
</children>
<stylesheets>
<URL value="#../../../../skins/default.css" />
</stylesheets>
</HBox>
</children>
</AnchorPane>
The code of the file where the above FXML is loaded:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<?scenebuilder-preview-i18n-resource ../lang/ru_RU.properties?>
<AnchorPane id="AnchorPane" fx:id="mainStage" cache="true" cacheHint="SPEED" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="UI.PrimaryStageController">
<children>
<StackPane fx:id="toolbarStack" alignment="CENTER_LEFT" cache="true" cacheHint="SPEED" prefHeight="100.0" prefWidth="1280.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="100.0" AnchorPane.topAnchor="0.0">
<children>
<FlowPane fx:id="toolbarPane" cache="true" cacheHint="SPEED" maxHeight="-Infinity" minHeight="-Infinity" prefHeight="100.0" prefWidth="1280.0" style="">
<children>
<Button id="fileButton" fx:id="selectorButton" cache="true" cacheHint="SPEED" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#openSelector" prefHeight="100.0" prefWidth="100.0" text="%selectorButton" />
<Button fx:id="fileButton" cache="true" cacheHint="SPEED" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#openFileMenu" prefHeight="100.0" prefWidth="100.0" text="%fileButton">
<stylesheets>
<URL value="#../../skins/default.css" />
</stylesheets>
</Button>
<Button fx:id="toolsButton" cache="true" cacheHint="SPEED" mnemonicParsing="false" onAction="#openToolsMenu" prefHeight="100.0" prefWidth="100.0" text="Button" />
<Button fx:id="helpButton" cache="true" cacheHint="SPEED" mnemonicParsing="false" onAction="#openHelpMenu" prefHeight="100.0" prefWidth="100.0" text="Button" />
</children>
</FlowPane>
</children>
</StackPane>
<AnchorPane fx:id="contentPane" prefHeight="-1.0" prefWidth="-1.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="100.0" />
<Button cache="true" cacheHint="SPEED" mnemonicParsing="false" onAction="#closeApp" prefHeight="100.0" prefWidth="100.0" text="%exitButton" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
<stylesheets>
<URL value="#../../skins/default.css" />
</stylesheets>
</AnchorPane>
The first FXML is loaded into the AnchorPane with fx:id = "contentPane". For reasons I don't know ListView fx:id = "listView" doesn't resize during window resizing. Any ideas?
P.S. I use JavaFX 8

Resources