Consolidate XML End Tag on a single line
By default, it seems JAXB puts the end tag on the second line. For example:
<w:Element w:prefix="c" w:name="Person" w:isReference="false">
</w:Element>
Is there any way to tell the Marshaller to put the end tag on the same line so the output would be:
<w:Element w:prefix="c" w:name="Person" w:isReference="false"/>
I use JAXP+Sax to generate XML files. Here a sample example:
import java.io.*;
// SAX classes.
import org.xml.sax.*;
import org.xml.sax.helpers.*;
//JAXP 1.1
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.sax.*;
// PrintWriter from a Servlet
PrintWriter out = response.getWriter();
StreamResult streamResult = new StreamResult(out);
SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
// SAX2.0 ContentHandler.
TransformerHandler hd = tf.newTransformerHandler();
Transformer serializer = hd.getTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd");
serializer.setOutputProperty(OutputKeys.INDENT,"false");/////////////////////// Not Indented XML File but has smaller size
hd.setResult(streamResult);
hd.startDocument();
AttributesImpl atts = new AttributesImpl();
// USERS tag.
hd.startElement("","","USERS",atts);
// USER tags.
String[] id = {"PWD122","MX787","A4Q45"};
String[] type = {"customer","manager","employee"};
String[] desc = {"Tim@Home","Jack&Moud","John D'o�"};
for (int i=0;i<id.length;i++)
atts.clear();
atts.addAttribute("","","ID","CDATA",id);
atts.addAttribute("","","TYPE","CDATA",type[i]);
hd.startElement("","","USER",atts);
hd.characters(desc[i].toCharArray(),0,desc[i].length());
hd.endElement("","","USER");
hd.endElement("","","USERS");
hd.endDocument();
This line: serializer.setOutputProperty(OutputKeys.INDENT,"false");/////////////////////// Not Indented XML File but has smaller size sets the identation of the xml file. See whether there is an equivalent with JAXB
Hope that Helps
Similar Messages
-
Xml file read in a single line
HI All,
I have configured a scenario FILE-FILE to generate a XML file as output(input also xml file). It has created xml file successfully, and this file is transferred from ECC5.0 to 4.7. In 4.7 this xml file is read by a particular program in which it is reading the entire file as a single line. This means that its not detecting end of line.
How can I resolve this??
Plz suggest.
rgds,
anilHi Satish,
If I understand, the program needs to read an xml file as a single line. If so, look at Michal weblog /people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions
With this simple xslt program you can put a whole xml file into a string. If you also need the inverse, string to xml, looks at the Henrique Pinto reply on bottom of weblog
To use XSLT programs you have 2 options:
XSLT-ABAP Engine -> /people/r.eijpe/blog/2005/11/04/using-abap-xslt-extensions-for-xi-mapping
Or you can paste the xslt code in a txt file, zip the file and import it to XI as Imported Archives.
Hope it helps you
Ricardo.
Message was edited by: Ricardo Quintino -
XI XML Parser: tag content with "'", single apostrophe: invalid character
Hi all,
we import XML-documents with the file adapter in a sender channel. everything works well.
But if one of the XML-tag contents contains a single apostrophe ( ' ), then the XML parser stops with an error "An invalid character was found inside an entity reference. ". The message can not be processed. If I test the message content in the mapping -> no error.
When the single apostrophe is dereferenced by an additional single apostrophe the XML-File can be processed.
Question: does anybody know how this can be handled because it is not very nice of SAP XI to send single apostrophes in outgoing messages but cannot handle it in incoming messages from other systems? special adapter settings?
Thank you very much
regards
Hanscheck bhavesh reply
Suppress Special Character
also check
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/9420 [original link is broken] [original link is broken] [original link is broken]
Implementing a Java Mapping in SAP PI to remove Escape Sequences from a file -
PBDOM : Exporting to XML file gives a single line
I've been starting developing with PowerBuilder 12.5 a few weeks ago. I had to write some XML files, so I got familiar with the PBDOM library.
I can build a lot of different things, it's very nice, but one thing still bothers me :
In the output file, the whole XML is written on a single line.
I use the SaveDocument function.
For example, here is some code :
PBDOM_Document doc
PBDOM_Element noderoot, node1, node11, node12
doc = CREATE PBDOM_Document
doc.NewDocument("NodeRoot")
noderoot = doc.GetRootElement()
node1 = CREATE PBDOM_Element
node1.SetName("Node1")
noderoot.AddContent(node1)
node1.SetAttribute("Attr", "AttrValue")
node11 = CREATE PBDOM_Element
node11.SetName("Node11")
node11.AddContent("Here is a value")
node1.AddContent(node11)
node12 = CREATE PBDOM_ELEMENT
node12.SetName("Node12")
node12.AddContent("Here is another value")
node1.AddContent(node12)
doc.SaveDocument("myDoc.xml")
Here is the result when I open it with notepad++
<NodeRoot><Node1 Attr="AttrValue"><Node11>Here is a value</Node11><Node12>Here is another value</Node12></Node1></NodeRoot>
Whereas I wanted :
<NodeRoot> <Node1 Attr="AttrValue"> <Node11>Here is a value</Node11> <Node12>Here is another value</Node12> </Node1> </NodeRoot>
With the notepad++ XML tools plugin, I can use the "pretty print" function to get this nice representation. But I would like my file to be formatted this way from the beginning. I noticed that the "line ending" was set to UNIX format (indicator on bottom right of the window), but I'm working on Windows. When I use the menu to convert it to Windows format (CR+LF), it changes this indicator, but the code stays on one single line.
Is there a way to tell PBDOM to export the XML file with a nice output ?
Thank you !
Notes :
- Opening the XML file with Internet Explorer or Google Chrome gives me a nice vizualisation, with indentation, line breaks...
- Adding a <?xml version="1.0" encoding="ISO-8859-1" ?> does not help (I've been doing it while exporting some more complex files, but I still get the output on one line...)Here is a very simple powerbuilder example. It uses MSXML instead of PBDOM. See my comments for hints how to use it with PBDOM.
oleobject lole_dom, lole_root, lole_element1, lole_element11, lole_element12
oleobject lole_Writer, lole_saxreader
string ls_result
// build DOM (you don't need this if you use PBDOM)
lole_dom = create oleobject
lole_dom.ConnectToNewObject ("Msxml2.DOMDocument")
lole_root = lole_dom.CreateElement ("NodeRoot")
lole_dom.documentElement = lole_root
lole_element1 = lole_dom.CreateElement("Node1")
lole_root.AppendChild(lole_element1)
lole_element1.SetAttribute("Attr", "AttrValue")
lole_element11 = lole_dom.CreateElement("Node11")
lole_element11.AppendChild (lole_dom.CreateTextNode("Here is a value"))
lole_element1.AppendChild(lole_element11)
lole_element12 = lole_dom.CreateElement("Node12")
lole_element12.AppendChild (lole_dom.CreateTextNode("Here is another value"))
lole_element1.AppendChild(lole_element12)
// this saves the DOM without formatting
//lole_dom.save ("d:\testxml.xml")
// this part is for formating
lole_Writer = create oleobject
lole_saxreader = create oleobject
lole_Writer.ConnectToNewObject ("MSXML2.MXXMLWriter")
lole_saxreader.ConnectToNewObject ("MSXML2.SAXXMLReader")
lole_Writer.omitXMLDeclaration = True
lole_Writer.indent = True
lole_saxreader.contentHandler = lole_Writer
// instead of DOM you can also put a XML string to parser: lole_saxreader.parse ("<node>...</node>")
// so you can also use the PBDOM output directly
lole_saxreader.parse (lole_dom)
// here is your formatted output
ls_Result = lole_Writer.output
MessageBox ("", ls_result)
lole_writer.Disconnectobject( )
lole_saxreader.Disconnectobject( )
lole_dom.Disconnectobject( )
DESTROY lole_writer
DESTROY lole_saxreader
DESTROY lole_dom -
XML output - all tags in Single line?
Hi,
Scenario: HTTP----> XI --- > File(XML)/Proxy(abap).
Output XML file has the data in single line(all XML tags).
Now, issue with abap proxy which reads this XML file for sending attachment in email has length constraint(can not read if line length exceeds 255 chars).
Is there any option in XI, to print each pair of tags in each line(using carriage return or line feed?)
Please help.Mallik,
I do not think that this can be achieved in XML to XML (unless you can create a specific module and add to the module tab)
But if you create say a CSV or TXT file and use the <b>Content Conversion Parameters</b> option
Here you can specify the fieldSeparator to be 'nl'
<b>Input</b>
<?xml version="1.0" encoding="UTF-8"?>
<record>
<field1>f1</field1>
<field2>f2</field2>
<field3>f3</field3>
</record>
<b>Output</b>
f1
f2
f3
Here you have retained your data and each field is separated by a new line. Unfortunatley with this method you lose your XML tags
Regards,
Mike -
Can we have a multiple TAGS in single line.Pls let me know
Hi Team,
Can we have a multiple TAGS in single line.Ie 2 open tags and 2 close tags in XML..Pls let me knowchk this xml file
<ns0:Test1>
<Address><street>LinkinPark</street><city>Paris</city></Address>
</ns0:Test1>
But I am not sure whether u can have any value for parent node in 7.0 for like node Address... only child nodes can have value..
It can be done in 7.1
Regards,
Syed -
Download created XML File in batch mode // Parse XML file into single lines
Hello!
I upload a CSV file and based on that CSV file I create an XML "object". First I uploaded and downloaded it via gui frontendclass, but as it has to be run in a batch in the night I need to upload and download the data via OPEN DATASET.
The import and transformation of the CSV file works fine, also the transfer into an itab with the same structure as a CSV line is ok. I also create the XML file, which could be downloaded easily with gui-download but it is not permittet.
Import of data: I scan the folder and get the filenames into a itab, I loop over that itab and read the single files like this:
OPEN DATASET ls_convert_batch FOR INPUT IN TEXT MODE ENCODING DEFAULT.
CLEAR tab.
IF sy-subrc = 0.
DO.
READ DATASET ls_convert_batch INTO line.
IF sy-subrc <> 0.
EXIT.
ELSE.
CLEAR tmptab.
SPLIT line AT ';' INTO tmptab-product
tmptab-contract
tmptab-extagent.
APPEND tmptab TO tab.
ENDIF.
ENDDO.
ENDIF.
The XML file has a strucutre like
<file>
- <file formant_no="1.1" format_date="02.10.2003">
<status>V</status>
<number>001001025</numbner>
<name>Schmeisser,Christof</name>
- <details>
- <detail>
<contract>00000003494</contract>
<name>Schmeisser, Christof</name>
<invoice_no>000000003840</invoice_no>
<due_date>20100601</due_date>
<amount>140,00</amount>
</detail>
- <detail>
<contract>00000003495</contract>
<name>Schmeisser, Christof</name>
<invoice_no>000000003841</invoice_no>
<due_date>20100601</due_date>
<amount>130,00</amount>
</detail>
- </details>
<elements>2</elements>
<amount_overall>270</amount_overall>
</file>
At the moment I download it like this:
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = filename
filetype = 'BIN'
* CONFIRM_OVERWRITE = '0'
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF sy-subrc = 0.
lv_create_counter = lv_create_counter + 1.
ENDIF.
But I need to download it via OPEN TRANSFER CLOSE Dataset as it has to run in batch mode.
Anyone has an idea? I am really desperate here. One idea would be to parse the single lines into a string and then create the XML file line by line as text and save it with ending XML, should work. But I don't know how!
Thank you very much in advance,
kind regards from Tallinn, Estonia,
Christof!
Edited by: Christof Schmeisser on Nov 25, 2010 7:51 PM
I edited the heading, would be too general and missleading!Tipos Pools
TYPE-POOLS: ixml.
CLASS cl_ixml DEFINITION LOAD.
TYPES: BEGIN OF xml_node_type,
node TYPE char50,
vlnode TYPE string,
END OF xml_node_type,
BEGIN OF xml_line_type,
data(256) TYPE x,
END OF xml_line_type.
Tabelas Internas
DATA: ti_xml_node TYPE TABLE OF xml_node_type.
Variáveis TYPE REF
*Type REF para utilizar no XML
DATA: ixml_type TYPE REF TO if_ixml,
streamfactory_type TYPE REF TO if_ixml_stream_factory,
ostream_type TYPE REF TO if_ixml_ostream,
istream_type TYPE REF TO if_ixml_istream,
parser_type TYPE REF TO if_ixml_parser,
renderer_type TYPE REF TO if_ixml_renderer,
document_type TYPE REF TO if_ixml_document,
encoding_type TYPE REF TO if_ixml_encoding,
node_type TYPE REF TO if_ixml_node,
element_dtrans_type TYPE REF TO if_ixml_element,
element_xml_in_type TYPE REF TO if_ixml_element,
element_roteiros_type TYPE REF TO if_ixml_element,
element_roteiro_type TYPE REF TO if_ixml_element,
element_vias_type TYPE REF TO if_ixml_element,
element_via_type TYPE REF TO if_ixml_element,
element_dummy_type TYPE REF TO if_ixml_element,
gw_xml_node TYPE TABLE OF xml_node_type,
gw_xml_node_ret TYPE TABLE OF xml_node_type,
gw_xml_node_err TYPE TABLE OF xml_node_type,
gw_xml_node_xml TYPE TABLE OF xml_node_type,
gw_xml_table TYPE TABLE OF xml_line_type,
gw_xml_table2 TYPE TABLE OF xml_line_type,
gs_xml_node TYPE xml_node_type, "WA para leitura do xml
gs_xml_node_ret TYPE xml_node_type, "WA para leitura do xml retorno
gs_xml_node_err TYPE xml_node_type, "WA para leitura do xml erro
gs_xml_node_xml TYPE xml_node_type, "WA para leitura do xml info sucesso
gs_xml_table2 TYPE xml_line_type. "WA para importar xml
Variáveis do Programa
DATA: l_value TYPE string,
l_rc TYPE i,
l_xml_size TYPE i,
cod_cartaorepom TYPE char20 VALUE '123456789',
v_caminho_exp TYPE string VALUE 'C:TEMP',
v_salvaarquivo TYPE string,
v_nomearquivo TYPE string,
w_nodetext TYPE string,
v_roteiros TYPE string,
v_roteiro TYPE string,
v_roteiro_codigo TYPE string,
v_percurso_codigo TYPE string,
v_percurso_descricao TYPE string,
v_cidade_origem TYPE string,
v_estado_origem TYPE string,
v_cidade_destino TYPE string,
v_estado_destino TYPE string,
v_transporte_tipo TYPE string,
v_cartao_taxa TYPE string,
v_cobra_taxa TYPE string.
Constants
CONSTANTS: cc_39 TYPE string VALUE '39', " Numero 39.
cc_dt_trans TYPE string VALUE 'data_transfer'," document_type(name)
cc_metodo_cod TYPE string VALUE 'metodo_codigo'," document_type(name)
cc_xml_in TYPE string VALUE 'xml_in'," document_type(name)
cc_ct_tx_ativ TYPE string VALUE 'cartao_taxa_ativacao'," document_type(name)
cc_cartao TYPE string VALUE 'cartao', " Parâmetro Perform.
cc_xml TYPE string VALUE '.XML'," extenção
cc_bin TYPE char10 VALUE 'BIN'." filetype
START-OF-SELECTION.
PERFORM yf_inicia_criacao_xml USING cc_39.
element_roteiro_type = document_type->create_simple_element(
name = cc_ct_tx_ativ
parent = element_xml_in_type ).
PERFORM yf_dummy_roteiro USING cod_cartaorepom cc_cartao.
PERFORM yf_finaliza_xml.
PERFORM yf_exporta_xml USING v_caminho_exp.
PERFORM yf_convert_xml_to_itab TABLES gw_xml_node_ret
USING v_salvaarquivo.
END-OF-SELECTION.
*& Form yf_inicia_criacao_xml
text
-->VALUE(P_0783) text
FORM yf_inicia_criacao_xml USING value(p_0783).
DATA: s_encoding_type TYPE string VALUE 'ISO-8859-1'.
Cria o ixml factory
ixml_type = cl_ixml=>create( ).
*Cria o objeto com modelo
document_type = ixml_type->create_document( ).
*Cria o cabeçalho encoding="iso-8859-1"
encoding_type = ixml_type->create_encoding( byte_order = 0
character_set = s_encoding_type ).
*Cria o root "DATA_TRANSFER"
element_dtrans_type = document_type->create_simple_element(
name = cc_dt_trans
parent = document_type ).
*Cria o node "METODO_CODIGO" e preenche com um valor passado no L_VALUE
l_value = p_0783.
CONDENSE l_value.
element_dummy_type = document_type->create_simple_element(
name = cc_metodo_cod
value = l_value
parent = element_dtrans_type ).
*Cria o node "XML_IN"
element_xml_in_type = document_type->create_simple_element(
name = cc_xml_in
parent = element_dtrans_type ).
ENDFORM. " yf_inicia_criacao_xml
*& Form yf_dummy_roteiro
text
-->VALUE(P_0996) text
-->VALUE(P_0997) text
FORM yf_dummy_roteiro USING value(p_0996)
value(p_0997).
l_value = p_0996.
CONDENSE l_value.
element_dummy_type = document_type->create_simple_element(
name = p_0997
value = l_value
parent = element_roteiro_type ).
ENDFORM. " yf_dummy_roteiro
*& Form yf_finaliza_xml
text
FORM yf_finaliza_xml.
*Cria o stream factory
streamfactory_type = ixml_type->create_stream_factory( ).
*Conecta a internal table de XML com o stream factory
ostream_type = streamfactory_type->create_ostream_itable( table = gw_xml_table ).
CALL METHOD ostream_type->set_encoding
EXPORTING
encoding = encoding_type.
*Rendering the document
renderer_type = ixml_type->create_renderer( ostream = ostream_type
document = document_type ).
l_rc = renderer_type->render( ).
*Salva o documento XML
l_xml_size = ostream_type->get_num_written_raw( ).
ENDFORM. " yf_finaliza_xml
*& Form yf_exporta_xml
text
-->VALUE(P_0783) text
FORM yf_exporta_xml USING value(p_0783).
CONCATENATE cod_cartaorepom
sy-datum
sy-uzeit
cc_xml
INTO v_nomearquivo.
CONCATENATE p_0783
v_nomearquivo
INTO v_salvaarquivo.
TRANSLATE v_nomearquivo TO UPPER CASE.
*Exporta o XML
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = l_xml_size
filename = v_salvaarquivo
filetype = cc_bin
CHANGING
data_tab = gw_xml_table
EXCEPTIONS
OTHERS = 24.
IF sy-subrc = 0.
PERFORM yf_sapgui_progress_indicator USING cc_msg_xml_ok.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " yf_exporta_xml
*& Form yf_convert_xml_to_itab
text
-->P_GW_XML_NODE_RET text
-->P_FILENAME text
FORM yf_convert_xml_to_itab TABLES p_gw_xml_node_ret LIKE gw_xml_node
USING p_filename.
DATA l_count.
ixml_type = cl_ixml=>create( ).
Now Create Stream Factory
streamfactory_type = ixml_type->create_stream_factory( ).
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = p_filename
filetype = cc_bin
IMPORTING
filelength = l_xml_size
CHANGING
data_tab = gw_xml_table2
EXCEPTIONS
OTHERS = 19.
IF sy-subrc = 0.
istream_type = streamfactory_type->create_istream_itable( table = gw_xml_table2
size = l_xml_size ).
document_type = ixml_type->create_document( ).
parser_type = ixml_type->create_parser( stream_factory = streamfactory_type
istream = istream_type
document = document_type ).
IF parser_type->parse( ) NE 0.
IF parser_type->num_errors( ) NE 0.
l_count = parser_type->num_errors( ).
ENDIF.
ENDIF.
CALL METHOD istream_type->close( ).
CLEAR istream_type.
node_type = document_type.
PERFORM yf_get_data USING node_type.
p_gw_xml_node_ret[] = gw_xml_node[].
CLEAR gw_xml_node[].
ENDIF.
ENDFORM. " yf_convert_xml_to_itab
*& Form yf_get_data
text
-->VALUE(X_NODE) text
FORM yf_get_data USING value(x_node) TYPE REF TO if_ixml_node.
DATA: indent TYPE i.
DATA: ptext TYPE REF TO if_ixml_text.
DATA: string TYPE string.
DATA: temp_string(100).
CASE x_node->get_type( ).
WHEN if_ixml_node=>co_node_element.
string = x_node->get_name( ).
w_nodetext = string.
CLEAR string.
string = x_node->get_value( ).
IF NOT w_nodetext IS INITIAL OR
NOT string IS INITIAL.
gs_xml_node-node = w_nodetext.
gs_xml_node-vlnode = string.
IF NOT gs_xml_node-vlnode IS INITIAL.
APPEND gs_xml_node TO gw_xml_node.
CLEAR gs_xml_node.
ENDIF.
ENDIF.
ENDCASE.
Get the next child
x_node = x_node->get_first_child( ).
Recurse
WHILE NOT x_node IS INITIAL.
PERFORM yf_get_data USING x_node.
x_node = x_node->get_next( ).
ENDWHILE.
ENDFORM. "yf_get_data -
hi I am having problem in formatting XML file which I generated with xmlelement() when I execute it gives me putput in a single line
is there any way that I got my output as a XML file HAS......That is expected behavior. PRETTY print(ing) is only needed for humans. XML Parsers don't need the XML to be pretty printed. If you open the XML file in a browser like Windows Explorer or Firefox, the browser will pretty print the output for you.
In all, the "single line" output is done because of PERFORMANCE reasons (lack of unneeded end of line and CTRL line breaks etc)
SELECT xmlelement("Employee Name", dummy) as "XML RESULT"
FROM DUAL;
<Employee Name>X</Employee Name>
SELECT xmlelement("Employee Name", xmlelement("SurName", dummy)
, xmlelement("LastName", dummy)
) as "XML RESULT"
FROM DUAL;
<Employee Name><SurName>X</SurName><LastName>X</LastName></Employee Name>
XMLSERIALIZE can pretty print the output if needed via INDENTation
SELECT XMLSERIALIZE(CONTENT xmlelement("Employee Name", xmlelement("SurName", dummy), xmlelement("LastName", dummy)) as CLOB indent SIZE=1 )
FROM DUAL;
<Employee Name>
<SurName>X</SurName>
<LastName>X</LastName>
</Employee Name> -
Mercator xml single line translation
hi guys,
I have a map that reads in an xml file and outputs an edifact msg.
When the xml is formatted, i.e spaced apart according to the tags, the map performs fine.
Unfortunately, my xml file is generated by another application that outputs the xml all on one single line.
i.e
<line1>A</line1><line2>B</line2><line3>C</line3>when i run the input file (single line xml) through the map, i get an invalid input message!!
I've already removed all the <cr> and <nl> from all the Terminators in my input type tree, but i still get an Invalid input error message. has anyone experianced this before?
Any help or suggestions are greatly appreciated.Mallik,
I do not think that this can be achieved in XML to XML (unless you can create a specific module and add to the module tab)
But if you create say a CSV or TXT file and use the <b>Content Conversion Parameters</b> option
Here you can specify the fieldSeparator to be 'nl'
<b>Input</b>
<?xml version="1.0" encoding="UTF-8"?>
<record>
<field1>f1</field1>
<field2>f2</field2>
<field3>f3</field3>
</record>
<b>Output</b>
f1
f2
f3
Here you have retained your data and each field is separated by a new line. Unfortunatley with this method you lose your XML tags
Regards,
Mike -
SQL CASE statement in XML template- End tag does not match start tag 'group
Hi All,
I am developing a report that has the SQL CASE statement in the query. I am trying to load this into RTF with report wizard and it gives me below error
oracle.xml.parser.v2.XMLParseException: End tag does not match start tag 'group'
Does XML publisher support CASE statement?
My query is something like this
SELECT customercode,
SUM(CASE WHEN invoicedate >= current date - 30 days
THEN balanceforward ELSE 0 END) AS "0-30",
SUM(CASE WHEN invoicedate BETWEEN current date - 60 days
AND current date - 31 days
THEN balanceforward ELSE 0 END) AS "31-60",
SUM(CASE WHEN invoicedate < current date - 60 days
THEN balanceforward ELSE 0 END) AS "61>",
SUM(balanceforward) AS total_outstanding
FROM MyTable
GROUP BY customercode
ORDER BY total_outstanding DESC
Please advice if the CASE statement or the double quotes are causing this error
Thanks,
PPI got this to work in the XML but the data is returning zeros for all the case statements. When I run this in toad I get results for all the case conditions but when ran in XML the data displayed is all zeros. I am not sure what I am missing. Can someone shed some light on this please
Thanks!
PP -
XML Parsing with Java - Only some attributes have start and end tags
Hello,
I am trying to interpret the XML response from a server after a HTTP request is sent to it. I have modified an example off Wikipedia below to give an example of what it looks like.
Example XML:
<Asset name="bread" prep_time="5 mins" cook_time="3 hours">
<Attribute name="Ingredient: ">Flour</Attribute>
<Attribute name="Ingredient: ">Water</Attribute>
<Attribute name="Used in Recipes:" />
</recipe>
I have been trying to display the above XML in a format such as:
name: bread prep_time: 5 mins cook_time: 3 hours
Ingredient: Flour
Ingredient: Water
Used in Recipes:
Right now I have been trying to do it manually using indexOf and substring of the XML text, but I would like to find a better way of doing this. I have found some examples online that show had to deal with cases such as
<person>
<first>Kiran</first>
<last>Pai</last>
<age>22</age>
</person>
but I do not know what to do when I encounter something like the last item, when there are no "Used in Recipe" items, and it ends with a />, instead of an ending tag </Attribute>.
Are there any suggestions as to how to handle the example XML code that I have posted?
Any help would be appreciated. Thanks.jtahlborn wrote:
Tolls wrote:
I suppose so, but since the idea is to turn it into text in a different format, XSLT strikes me as a better fit than hand crafting it.i agree if the end goal is formatted text. however, i wasn't sure if the OP was just writing some test code to figure out how to access the data or if the formatted text was the final desired output.No, true. It is open to interpretation.
jschell wrote:
(Quoting the same bit)
As long as one is mindful of the potential performance and maintenance impacts of course.Again, it depends what he's doing...true. I was making some assumptions, since (as usual) we don't really know the requirements beyond a base technical one (ie "I have this, and I need it to look like this"). In general, though, if you have XML data and you need it formatted differently then I'd say your first port of call ought to be transformation.
As for maintenance, I'd say it's easier to maintain a stylesheet than to modify Java, which is why I say it ought to be the start point.
Of course, YMMV. -
Long paragraphs in incoming emails display as a single line, with the end of the paragraph running off the screen. I want to make it wrap automatically to fit the screen.
For the browser window, just drag it to the top left of the screen (click and hold on the top bar with the traffic lights to drag), then in the bottom right of the window you'll see a rectangle with diagonal hatching. Click and hold on that and drag the window to the size you want.
Clicking on the green dot at top left will expand the window to fit the screen, clicking it again will shrink it back to where it was (this doesn't work in Finder windows quite the same).
The menu bar size is set in the bowels of the OS, though there may be third-party applications which can alter it.
As it's size is relative to the screen resolution, you could try reducing the resolution in System Preferences > Displays to see if that would suit you better. -
HTTP Receiver Adapter payload as single line plain text with out any tags.
Hi PI experts,
I have a strange problem in http receiver adapter.
Sender RFC (SAP) Receiver: HTTP.
Receiver system expects the output from XI in the below format in a single line plain text with out any tags in the payload. and the content type should be application/x-www-form-urlencoded
Group=Test&Sentinel=Web%20Server&Facility=5345&Order Number=XT-XWHM-Y-NA&Serial Number=123456&@LABEL_QUANTITY=5&@LABEL_NAME=111114_Q
Is there any way to achieve this using http receiver adapter. Business is not ready to accept the output from XI not even in a single element instead they only need it as a JUST a plain text.
Appreciate early response on this.
Thanks in Advance,
JitenderDear Ola,
Could you elaborate how you achieved in catching the response data from the receiver in case of HTTP receiver adapter?
The target service is not a WebService but some python script that must to receive some paramters via POST request.
HOW can I post this parameters?
Here you entered the fields of the message type of the request in the header parameters of the receiver adapter? Thats fine.
But what about the message type and vice versa of the response from the receiver?
Regards
Rebecca -
Trying to publish an event to fb from iPhoto '09, 8.1.2. Getting error message: "Line 22: Opening and ending tag mismatch: meta line 0 and head". Never had any trouble before. What in the world?
See if you can export those same photos to a folder on your Desktop.
OT -
TSQL XML query Results tab: elements crammed together as single line
Are the elements in a TSQL "FOR XML..." query rendered by default as a single line (wrapped-around)?(i have a screen shot but i am not allowed to post it here until my acct is 'verified').
When i run
SELECT
c.CustomerID AS '@CustomerID',
(SELECT
oh.SalesOrderID, oh.Status
FROM
Sales.SalesOrderHeader oh
WHERE
c.CustomerID = oh.CustomerID
FOR XML PATH('Order'), TYPE) AS Orders
FROM
Sales.Customer c
WHERE
EXISTS (SELECT * FROM Sales.SalesOrderHeader soh WHERE c.CustomerID = soh.CustomerID)
FOR XML PATH ('Customer'), ROOT ('Customers')
this is what i get:
<Customers><Customer CustomerID="11000"><Orders><Order><SalesOrderID>43793</SalesOrderID><Status>5</Status></Order><Order><SalesOrderID>51522</SalesOrderID><Status>5</Status></Order><Order><SalesOrderID>57418</SalesOrderID><Status>5</Status></Order></Order
tus>5</Status></Order></Orders></Customer><Customer CustomerID="11008"><Orders><Order><SalesOrderID>43826</SalesOrderID><Status>5</Status></Order><Order><SalesOrderID>51282</SalesOrderID><Status>5</Status></Order><Order><SalesOrderID>53765</SalesOrderID><S
rderID>
Why aren't the results with XML elements nicely ordered, one element per line?
<Customer CustomerID="11000">
<Orders>
<Order>
<SalesOrderID>43793</SalesOrderID>.....Where are you viewing the result? In SQL Management studio the result will be shown as link which when you click will show XML elements ordered nicely
I've shown some examples here
http://visakhm.blogspot.in/2014/05/t-sql-tips-fun-with-for-xml-path.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Maybe you are looking for
-
How can i use AME for the new OAF page.
Dear all, I have developed a new OAF page and registered under Employee Self Service. How can i use AME for the approval process. Appreciate your ideas? zamora
-
Does AQ 9.0.1 actually work with OC4J 9.0.2?
Hello, I have been trying to get my MDB running on OC4J 9.0.2 to write to the database upon the receipt of a message, but has been unsuccessful in doing so. Here is the source of my sample MDB to demonstrate the point: import java.sql.*; import javax
-
Hi, I have one problem.....I have craeted PO with few condition types.....Now i enetred value manually in fron of each condition type... Now i saved the PO.. My problem is , the movement i am creating ainother PO, once i entered vendor and material
-
Hi Folks, I'm doing a scenario from proxy to soap. in that I'm fetching the data from the tables in the SAP system using the proxy and sending the same to the webservice through the SOAP adapter configured in the Receiver end. basically I have th
-
Mail crashes after about 30 seconds and also before I can delete any items.