OpenEdge Progress 4GL WRITE-XML NAMESPACE-PREFIX - openedge

Hi Progress OpenEdge dev,
I am using the following syntax to generate an XML file from temp table. All is good but for one item.
dataset dsCust:write-xml("FILE", "c:/Test/Customer.xml", true).
This is my temp table declaration
def temp-table ttCustomer no-undo
namespace-uri "http://WMS.URI"
namespace-prefix "ns0"
field PurchaseOrderNumber as char
field Plant as char.
This is my output
<ns0:GoodsReceipt xmlns:ns0="http://WMS.URI">
<ns0:PurchaseOrderNumber/>
<ns0:Plant>Rose</ns0:Plant>
</ns0:GoodsReceipt>
But this is my desired output
<ns0:GoodsReceipt xmlns:ns0="http://WMS.URI">
<PurchaseOrderNumber/>
<Plant>Rose</Plant>
</ns0:GoodsReceipt>
Notice the element inside GoodsReceipt node does not have ns0 prefix.
Can this achived using write-xml? I want to avoid using DOM or SAX if possible.
Thank you

You can always manually set attributes and tag-names using XML-NODE-TYPE and SERIALIZE-NAME.
However: I've worked with lot's of xml:s and API:s together with Progress OpenEdge and have yet to fail based on namespace-problems but I guess it might depend on what you want to do with the data.
Since you don't include the entire dataset this is something of a guess. It produces more or less what you want for this specific case. I don't know how multiple "receipts" should be rendered though so you might need to change this.
DEFINE TEMP-TABLE ttCustomer NO-UNDO SERIALIZE-NAME "ns0:GoodsReceipt"
FIELD xmlns AS CHARACTER SERIALIZE-NAME "xmlns:ns0" INITIAL "http://WMS.URI" XML-NODE-TYPE "ATTRIBUTE"
FIELD PurchaseOrderNumber AS CHARACTER
FIELD Plant AS CHARACTER .
DEFINE DATASET dsCust SERIALIZE-HIDDEN
FOR ttCustomer .
CREATE ttCustomer.
ASSIGN Plant = "Rose".
DATASET dsCust:write-xml("FILE", "c:/temp/Customer.xml", TRUE).

From a quick Google on the subject, it seems the W3C suggests that the namespace prefix should be presented the way OpenEdge does it: https://www.w3schools.com/xml/xml_namespaces.asp
And I'm pretty certain you can't change the behaviour with write-xml like you want to either. The documentation doesn't mention any way of overriding the behaviour. https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvxml/namespace-uri-and-namespace-prefix.html

Related

How to converts a character to decimal on progress 4GL?

DEFINE VARIABLE cDateTime AS CHARACTER NO-UNDO.
DEFINE TEMP-TABLE tt_data NO-UNDO
FIELD DateTime AS DECIMAL FORMAT "->>,>>9.99".
ASSIGN
cDateTime = "20191604121566".
CREATE tt_data.
ASSIGN
tt_data.DateTime = DECIMAL(cDateTime) /* Message Date and Time */
But it says:
"Value cannot be displayed using ->>>,>>>,>>9.999999".
Could you please help this case and tell me what is wrong here?
The code that you show does not result in the error that you are reporting.
I'm guessing that you have a DISPLAY statement somewhere in your real code.
The reported error simply means that that DISPLAY format is not wide enough for the data. By default DISPLAY will use whatever format you specified in the definition of a data element. If you did not specify anything then every datatype also has a default. For decimals the default is "->>,>>>.99".
You can either increase the format in the definition or override it in the display statement like so:
display tt_data.DateTime format ">>>>>>>>>>>>>>>9".
Note: the display format has no influence on the values that you can store in a field. You can always "overstuff" more data into a variable than you can display. The format is only for output display purposes -- it has nothing to do with storage.
The assignment works fine, however the display not.
So ...
DISPLAY tt_data.DateTime.
... does not work because it uses format "->>,>>9.99".
You can change the format in the definition, for example "99999999999999", or do:
DISPLAY tt_data.DateTime FORMAT "99999999999999".

teradata : to calulate cast as length of column

I need to use cast function with length of column in teradata.
say I have a table with following data ,
id | name
1|dhawal
2|bhaskar
I need to use cast operation something like
select cast(name as CHAR(<length of column>) from table
how can i do that?
thanks
Dhawal
You have to find the length by looking at the table definition - either manually (show table) or by writing dynamic SQL that queries dbc.ColumnsV.
update
You can find the maximum length of the actual data using
select max(length(cast(... as varchar(<large enough value>))) from TABLE
But if this is for FastExport I think casting as varchar(large-enough-value) and postprocessing to remove the 2-byte length info FastExport includes is a better solution (since exporting a CHAR() will results in a fixed-length output file with lots of spaces in it).
You may know this already, but just in case: Teradata usually recommends switching to TPT instead of the legacy fexp.

AssertResultSetsHaveSameMetaData in TSQLT

I am using TSQLT AssertResultSetsHaveSameMetaData to compare metadata between two tables.But the problem is that i cannot hardcode the table name since i am passing the table name as the parameter at the runtime.So is there any way to do that
You use tSQLt.AssertResultSetsHaveSameMetaData by passing two select statements like this:
exec tSQLt.AssertResultSetsHaveSameMetaData
'SELECT TOP 1 * FROM mySchema.ThisTable;'
, 'SELECT TOP 1 * FROM mySchema.ThatTable;';
So it should be quite easy to parameterise the names of the tables you are comparing and build the SELECT statements based on those table name parameters.
However, if you are using the latest version of tSQLt you can also now use tSQLt.AssertEqualsTableSchema to do the same thing. You would use this assertion like this:
exec tSQLt.AssertEqualsTableSchema
'mySchema.ThisTable'
, 'mySchema.ThatTable';
Once again, parameterising the tables names would be easy since they are passed to AssertEqualsTableSchema as parameters.
If you explain the use case/context and provide sample code to explain what you are trying to do you stand a better chance of getting the help you need.

Using Marklogic Xquery data population

I have the data as below manner.
<Status>Active Leave Terminated</Status>
<date>05/06/2014 09/10/2014 01/10/2015</date>
I want to get the data as in the below manner.
<status>Active</Status>
<date>05/06/2014</date>
<status>Leave</Status>
<date>09/10/2014</date>
<status>Terminated</Status>
<date>01/10/2015</date>
please help me on the query, to retrieve the data as specified above.
Well, you have a string and want to split it at the whitestapces. That's what tokenize() is for and \s is a whitespace. To get the corresponding date you can get the current position in the for loop using at. Together it looks something like this (note that I assume that the input data is the current context item):
let $dates := tokenize(date, "\s+")
for $status at $pos in tokenize(Status, "\s+")
return (
<status>{$status}</status>,
<date>{$dates[$pos]}</date>
)
You did not indicate whether your data is on the file system or already loaded into MarkLogic. It's also not clear if this is something you need to do once on a small set of data or on an on-going basis with a lot of data.
If it's on the file system, you can transform it as it is being loaded. For instance, MarkLogic Content Pump can apply a transformation during load.
If you have already loaded the content and you want to transform it in place, you can use Corb2.
If you have a small amount of data, then you can just loop across it using Query Console.
Regardless of how you apply the transformation code, dirkk's answer shows how you need to change it. If you are updating content already in your database, you'll xdmp:node-delete() the original Status and date elements and xdmp:node-insert-child() the new ones.

No Way to Format Cell as Month-Date-Year in PHPExcel?

I've am trying to format cells in an Excel document I create with PHPExcel using the setFormatCode method. I've been going through the list of 'FORMAT_DATE_xxxxxxx' options associated with this method, but I've been unable to find one that lists the month, date, and year in that order. Did I miss something here?
You missed FORMAT_DATE_XLSX14 and FORMAT_DATE_XLSX22
You also missed the fact that these are simply predefined string values, and that you can use any valid Excel numberformat string value that you set yourself.
$objPHPExcel->getActiveSheet()->getStyle('C9')
->getNumberFormat()
->setFormatCode(
'mm-dd-yyyy' // my own personal preferred format that isn't predefined
);

Resources