i want to print xml header with xmldom. The problem is, it prints only the xml version but missing the encode information.
What i got :
<?xml version="1.0"?>
What i want:
<?xml version="1.0" encoding="UTF-8"?>
im using ORACLE 11g
And here is what i got so far:
doc := xmldom.newdomdocument;
xmldom.setversion(doc,'1.0');
xmldom.setCharset(doc,'UTF-8');
mainNode := xmldom.makeNode(doc);
rootElmt := xmldom.createElement(doc,'Dokument');
rootNode := xmldom.appendChild (mainNode,xmldom.makeNode(rootElmt));
SetCurNode (rootNode);
dbms_lob.createTemporary(vClob,true);
dbms_xmldom.writeToClob (doc,vClob);
xmldom.freedocument (doc);
Thanks in advance,
Ivan
Not entirely sure why charset isn't included in the output, but it seems to be a common issue. One alternative (shown here: https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:2791321000346652231) is to do the following:
xmldom.setVersion(doc,'1.0" encoding="UTF-8');
Edit: Apparently, the character set you specify is ignored unless you use the writeToFile procedure, this would explain why it is not being included in the output when using writeToClob
Related
I'm trying to read a file with pig and I have the error indicated in the title.
data = LOAD '/user/cloudera/pigexample/commands' USING PigSorage('\n') as
(command:chararray);
DUMPdata;
The file contains the following:
**SOF**
whoami
pwd
ls
say
saw
source
<1>
source
<1>
exit
**EOF**
**SOF**
where's
<1>
I don't understand why I get the error supposedly its delimiter is the line break, I'm also trying with another file whose delimiter is the tab ('\t') and it doesn't work either. Does anyone know what the delimiter is? PS: I don't know what tag to put on the question.
As explained above, I expected it to open the file with the indicated delimiter but it does not work.
I have already tried with \t \n
I have already seen my mistake
data = LOAD '/user/cloudera/pigexample/commands' USING PigSorage('\n') as (command:chararray);
data = LOAD '/user/cloudera/pigexample/commands' USING PigStorage('\n') as (command:chararray);
I have a change log file,part of which looks like:
<include file="ChangeSets/00_SessionAuth.xml"/>
<include file="ChangeSets/01_Legacy_Baseline_V197_ANB.xml" context="legacy"/>
<include file="ChangeSets/02_V198_ANB.xml" context="non-legacy"/>
The change set 01_Legacy_Baseline_V197_ANB.xml has 197 sql scripts included,which are part of legacy database.
The change set 02_V198_ANB.xml is defined as:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<include file="ChangeSets/sql/Dummy_schema/V198_AddColumn.sql"/>
</databaseChangeLog>
When i run the Liquibase update with context as non legacy, i get the following error :
Unexpected error running Liquibase: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=SET SCEHMA = Dummy_schema;;BEGIN-OF-STATEMENT;<space>, DRIVER=3.62.56 [Failed SQL: SET SCEHMA = Dummy_schema;
The SQL file itself is correct.
I think this is an issue related to end delimiter or splitStatements.
The SQL goes like this:
SET SCEHMA = Dummy_schema;
ALTER TABLE T1 ADD COLUMN C1 VARCHAR(35)
ADD COLUMN C2 INTEGER;
Call Sysproc.admin_cmd ('REORG TABLE dummy_schema.T1');
ALTER TABLE T2 ADD COLUMN CT1 INTEGER;
Call Sysproc.admin_cmd ('REORG TABLE dummy_schema.T2');
We are using DB2 V10.5.
Can someone also provide the list of attributes,we can use with tag.
Regards
I think your assertion that
the SQL file itself is correct
is incorrect. That is valid SQL if it was run through the db2 command line application, but it is not valid SQL to be sent through a JDBC query, which is what Liquibase does.
The following lines of code generate me an XML file looking like the below set, which is almost acceptable to my client. I say ALMOST because the one change I need to to have <?xml version="1.0" encoding="UTF-8"?> versus the standard <?xml version="1.0"> which is at the top of every XML file I generate using the EXEC xp_cmdshell command below. I essentially need <?xml version="1.0" encoding="UTF-8"?> instead of <?xml version="1.0">. Can someone please tell me how this can be accomplished?
-- SQL CODE USED TO GENERATE XML FILE - Using XML Path
SET #FileString = #FileName + '.xml" -S ALSCG-JPATHIL\SQLEXPRESS -T -c -t,'
SET #SQLSTRING = 'bcp ";WITH XMLNAMESPACES (DEFAULT ''urn:CP-xml'') select A.TargetSystem AS ''Header/Target'' from [Header] A FOR XML PATH(''Qty'')" queryout "C:\Program Files\'
SET #SQLSTRING = #SQLSTRING + #FileString
EXEC xp_cmdshell #SQLSTRING
-- XML FILE CONTENTS GENERATED - Missing the Encoding Condition here
<?xml version="1.0">
<Qty xmlns="urn:CP-xml">
<Header>
<Target></Target>
</Header>
</Qty>
-- XML FILE CONTENTS DESIRED - Note only difference is the Encoding!
<?xml version="1.0" encoding="UTF-8"?>
<Qty xmlns="urn:CP-xml">
<Header>
<Target></Target>
</Header>
</Qty>
The very last response in this link has the only "solution" to this problem that I've been able to find
Hi, (late response but might help someone in future) VARBINARY did not
work for me, probably 'coz of the my datasource didn't comply. Heres
what worked for me at the SQL end;
1) Store your raw xml data as VARCHAR or TEXT (instead of NVARCHAR or
NTEXT) into a variable,
2) Read this variable into the xml data type using utf-8 encoding.
Something like:
DECLARE #TempHTMLText
SET #TempHTMLText = --your raw xml data DECLARE #XMLDataText XML
SELECT #XMLDataType = '<?xml version="1.0" encoding="utf-8" ?>' + #TempHTMLText
I don't think you'd need to do exactly that, rather use the following query:
DECLARE #Xml XML;
WITH XMLNAMESPACES(DEFAULT 'urn:CP-xml')
SELECT #Xml = (select A.TargetSystem AS 'Header/Target' from [Header] A FOR XML PATH('Qty'));
SELECT CONCAT('<?xml version="1.0" encoding="utf-8" ?>', CAST(#Xml AS VARCHAR(MAX)))
Note that in my testing, I was unable to convert this data back to XML while preserving the encoding tag. That seems to be enforced explicitly by the XML data type
I have one requirement where entire response structure will be varied based on the current element. but in dataweave $ is not accessible with when, but with function it is accessible. Could you please suggest am i missing some thing here?
[1,2,5] map $ when $ > 1 otherwise 2 throws error. but same used like the below way works.
%function r(a) a when a > 1 otherwise 2
---
[1,2,5] map r($)
Could you please help me to understand the behaviour.
Thanks
Sushma.
I found the answer after posting the question!!
it works with braces.
[1,2,5] map ($ when $ >1 otherwise 2)
Thanks
Sushma
As formerly stated here, I am trying to recreate an SSH profile manager in Pascal that I had originally written in Ruby. With the answer provided I have been able to get the shell to stay open and accept input. Now I have the new problem of any and all input is hidden and all output seems to be tiling with several tab characters before each line. The updated relevant code is as follows:
if HasOption('c', 'connect') then begin
TempFile:= GetRecord(GetOptionValue('c', 'connect'));
AProcess:= TProcess.Create(nil);
AProcess.Executable:= '/usr/bin/ssh';
AProcess.Parameters.Add('-p');
AProcess.Parameters.Add(TempFile.Port);
AProcess.Parameters.Add('-tt');
AProcess.Parameters.Add(TempFile.Username + '#' + TempFile.Address);
AProcess.Options:= [];
AProcess.ShowWindow:= swoShow;
AProcess.InheritHandles:= False;
AProcess.Execute;
AProcess.WaitOnExit;
AProcess.Free;
Terminate;
Exit;
end;
The output provide looks like this:
I ran ls, pwd, and exit in that order.
So probably you use crt or some other terminal library that puts the terminal into raw mode, requiring both a cr and lf.
Remove crt from the uses clause, and probably it will go better