Wrapping xml-fragment into AnyDocument looses runtime type information
I would like to store a fragment of xml in a database. However, to stay XML compatible,
I don't want to have <xml-fragment> tags. To avoid this, I attempt to "wrap"
the xml-fragment inside of an AnyDocument using the following code:
private static AnyDocument wrap(final XmlObject o) {
final AnyDocument anyDocument = AnyDocument.Factory.newInstance();
final AnyDocument.Any any = anyDocument.addNewAny();
any.set(o);
return anyDocument;
The problem, is that somehow my runtime type is getting lost after the wrapping
occurs.
Here is how the data looks BEFORE wrap (o.save()):
<?xml version="1.0" encoding="UTF-8"?>
<xml-fragment xsi:type="loc:AddTermRequestT" xmlns:loc="http://www.overture.com/service/common/local"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dis="http://www.overture.com/service/display">
<loc:accountId>1123223ZZZ</loc:accountId>
<loc:term>dog</loc:term>
<loc:price>0.55</loc:price>
</xml-fragment>
Note that in the above XML the runtime type is set as: xsi:type="loc:AddTermRequestT
Here is how the data looks after I attempt to wrap it with AnyDocument:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:any xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:dis="http://www.overture.com/service/display"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:loc="http://www.overture.com/service/common/local">
<loc:accountId>1123223ZZZ</loc:accountId>
<loc:term>dog</loc:term>
<loc:price>0.55</loc:price>
</xsd:any>
The runtime type is gone and it's not clear how to parse the new XML.
Am I doing something wrong? Why does the runtime type go away? Is this the correct
way to "warp" some fragment with a valid document.
Again, the intent here is to store something to the database that a different
tool can understand later.
Thanks.
-AP_
Use:
xmlOptions.setSaveOuter();
Similar Messages
-
Adding XML fragments to a document in a XMLType table
Hi,
Is there a direct way to insert an XML fragment into a
document held in a XMLtype, or does this have to be done
via the updatexml function?
thanks
PeteThank you Jeffrey. I converted the file to PDF and it worked! Very happy.
-
How to store XML fragments in a XMLTYPE column
Hi all,
maybe just another newbie question.
I've imported a lot of xml documents into an Oracle table with a xmltype column (stored as CLOB). Now I try to select a specific part of these documents and store thsi xml fragment in another table, also in a xmltype column.
Unfortunately this doesn't work, I get ORA-19010: Cannot insert XML fragments.
What can I do to store part of a xml document?
Best regards
MatthiasIs there a way to transform the xml fragments into valid xml documents?
-
Casting a result-tree-fragment into a node set
Hi,
Is there anything in BI Publisher that converts a result-tree-fragment into a node set, which resembles the node-set function in as in the following link? http://www.exslt.org/exsl/functions/node-set/
Thanks,
JonathanHi,
Seems no one understands my need in my post yet. Let me elaborate my requirement a little more...
Actually in my case, I used a variable to refer to a node set (in my actual implementation the conditions in the bracket [] are much much more complicated ), e.g.
<?variable:rows;”/ROWSET/ROW[SALARY>1000]”?>
And since the report involves a complex layout printed on pre-print forms which needs me to put the fields very precisely. I cannot use the For Each method but to extract the rows one by one, likes the following:
<?$rows[1]/ENAME?>
<?$rows[2]/ENAME?>
and put them on various position on the RTF Template.
So far so good, until I realized that the $rows node set is needed to be sorted according to ENAME.
Currently I can build a sorted list from $rows into another variable $sorted_rows as follows:
<xsl:variable name="sorted_rows"><xsl:for-each select="$rows"><xsl:sort select="ENAME"/><xsl:copy-of select="."/></xsl:for-each></xsl:variable>
But in $sorted_rows, it contains only one item which is the xml fragment of the sorted data, but not a node set.
So my question is, is there any way to convert this xml fragment into a node set so I can use the following to extract the fields?
<?$sorted_rows[1]/ENAME?>
<?$sorted_rows[2]/ENAME?>
Hope anyone can share with my some solution to this.
Thanks in advance,
Jonathan -
How to ftp XML document into a XML type which is not created by itself.
Hi,
1.
I have a table call SNPLEX_DESIGN which is created automaticly when I register a snplex_design.xsd XML schema.( Oracle creates it through the xdb:defaultTable="SNPLEX_DESIGN attribute). and it is created using SNPLEX user account.
2.
I also created a folder (resource) call /home/SNPLEX/Orders. which is used to hold all the incoming XML document.
3.
I created another user account call SNPLEX_APP, which is the only user account allowed to FTP XML document into /home/SNPLEX/Orders folder.
Isuues,
If I login as SNPLEX user, I can ftp XML document into the folder and TABLE (the file size = 0). But If I login as SNPLEX_APP user account, I can only ftp XML document into the folder, but Oracle doesn't store the document into the table( becuase the files size shows a number).
I have granted all the ACL privileges on the /home/SNPEX/Orders folder to SNPLEX_APP hrough OEM.
DO I miss anything. Any helps will be great appreciated. Resolve this issues is very import to us, sicne we are on a stage to roll system into production.
Regards,
JinsenIN order for a registered schema to be available to other users the schema must be registered as a GLOBAL, rather than a LOCAL Schema. This is controlled by the third agument passed to registerSChema, and the default is local. Note that you will also need to explicity grant appropriate permissions on any tables created by the schema registration process to other users who will be loading or reading data from these tables.
-
Hi Experts,
I have a XML file on my desk top.
How to upload data from XML file into ITAB?
Regardscheck this code
this mat be useful to u
REPORT Z_NTVI_XML_TO_ABAP .
Load iXML Lib.
type-pools: ixml.
class cl_ixml definition load.
data: G_IXML type ref to if_ixml.
data: STREAMFACTORY type ref to if_ixml_stream_factory.
data: ISTREAM type ref to if_ixml_istream.
data: DOCUMENT type ref to if_ixml_document.
data: PARSER type ref to if_ixml_parser.
data: LV_FILE_URL type rlgrap-filename.
You should provide the parameter for file name
LV_FILE_URL = 'C:input_xml.xml'.
types: begin of XML_LINE,
DATA(256) type x,
end of XML_LINE.
types: begin of TY_HEADER,
CUST_NAME(20) type c,
CARD_NO(20) type c,
TAX_AMOUNT(10) type c,
TOTAL_AMOUNT(10) type c,
end of TY_HEADER.
types: begin of TY_ITEM,
ITEM_NO(4) type n,
ITEM_ID(20) type c,
ITEM_TITLE(50) type c,
ITEM_QTY(10) type c,
ITEM_UPRICE(10) type c,
end of TY_ITEM.
data: GV_HEADER type TY_HEADER.
data: GT_ITEM type standard table of TY_ITEM with header line.
data: XML_TABLE type table of XML_LINE,
XML_TABLE_SIZE type i.
The next step is creating the main factory for the iXML library:
G_IXML = cl_ixml=>create( ).
Now Create Stream Factory
STREAMFACTORY = G_IXML->create_stream_factory( ).
upload a file from the client's workstation
call function 'WS_UPLOAD'
exporting
filename = LV_FILE_URL
filetype = 'BIN'
importing
filelength = XML_TABLE_SIZE
tables
data_tab = XML_TABLE
exceptions
others = 11.
wrap the table containing the file into a stream
ISTREAM = STREAMFACTORY->create_istream_itable( table = XML_TABLE
size = XML_TABLE_SIZE )
Get the file data as Stream
*istream = streamfactory->create_istream_uri( public_id = lv_file_url
system_id = lv_file_url ).
Create XML Document instance
DOCUMENT = G_IXML->create_document( ).
Create parser Object
PARSER = G_IXML->create_parser( stream_factory = STREAMFACTORY
ISTREAM = istream
DOCUMENT = document ).
Parse an XML document into a DOM tree
*parser->parse( ).
Parsing Error Processing
if PARSER->parse( ) ne 0.
if PARSER->num_errors( ) ne 0.
data: PARSEERROR type ref to if_ixml_parse_error,
STR type STRING,
I type i,
COUNT type I,
INDEX type i.
COUNT = PARSER->num_errors( ).
write: COUNT, ' parse errors have occured:'.
INDEX = 0.
while INDEX < COUNT.
PARSEERROR = PARSER->get_error( INDEX = index ).
I = PARSEERROR->get_line( ).
write: 'line: ', i.
I = PARSEERROR->get_column( ).
write: 'column: ', i.
STR = PARSEERROR->get_reason( ).
write: STR.
INDEX = index + 1.
endwhile.
endif.
endif.
Close the stream since it �s not needed anymore
call method ISTREAM->close( ).
clear ISTREAM.
Now try to make it look good
data : lv_size type sytabix,
lv_ret_code type sysubrc.
data: lo_xml_document type ref to cl_xml_document.
field-symbols: <fs_xml_data> type any table.
lo_xml_document = document.
call method lo_xml_document->get_as_table
importing
table = <fs_xml_data>
size = lv_size
retcode = lv_ret_code
*data: items type ref to if_ixml_node_collection.
*items = document->get_elements_by_tag_name( name = 'Item' ).
*data: iterator type ref to if_ixml_node_iterator,
node type ref to if_ixml_node.
*iterator = document->create_iterator( ).
*node = iterator->get_next( ).
*while not node is initial.
do something with the node
node = iterator->get_next( ).
*endwhile.
DATA : GV_NODE type ref to if_ixml_node.
DATA : GV_NODETEXT type STRING.
data: GV_FIRST_TIME.
GV_FIRST_TIME = 'X'.
GV_NODE = DOCUMENT.
GT_ITEM-item_no = 1.
perform GET_DATA tables GT_ITEM
using GV_NODE
changing GV_HEADER.
Last item is still not added.
append GT_ITEM.
write : GV_HEADER-cust_name,
GV_HEADER-card_no,
GV_HEADER-tax_amount,
GV_HEADER-total_amount.
loop at GT_ITEM.
write /:.
write : GT_ITEM-item_no,
GT_ITEM-item_id,
GT_ITEM-item_title,
GT_ITEM-item_qty,
GT_ITEM-item_uprice.
endloop.
FORM Get_data *
form get_data tables YT_ITEM structure GT_ITEM
using value(x_node) type ref to if_ixml_node
changing Y_HEADER type TY_HEADER.
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( ).
GV_NODETEXT = STRING.
when if_ixml_node=>co_node_text.
PTEXT ?= X_NODE->query_interface( IXML_IID_TEXT ).
if PTEXT->ws_only( ) is initial.
STRING = X_NODE->get_value( ).
case GV_NODETEXT.
when 'Customer'.
clear GV_HEADER.
when 'Name'.
move STRING to GV_HEADER-cust_name.
when 'Cardnum'.
move STRING to GV_HEADER-card_no.
when 'Tax'.
move STRING to GV_HEADER-tax_amount.
when 'Total'.
move STRING to GV_HEADER-total_amount.
Iteam details
when 'ID'.
move STRING to GT_ITEM-item_id.
when 'Title'.
move STRING to TEMP_STRING.
move TEMP_STRING to GT_ITEM-item_title.
when 'Quantity'.
move STRING to GT_ITEM-item_qty.
when 'UnitPrice'.
move STRING to GT_ITEM-item_uprice.
endcase.
endif.
endcase.
if GV_NODETEXT = 'Customer'.
clear GV_HEADER.
elseif GV_NODETEXT = 'Item'.
if GV_FIRST_TIME ne 'X'.
append GT_ITEM.
clear : gt_item.
GT_ITEM-item_no = gt_item-item_no + 1.
endif.
GV_FIRST_TIME = ' '.
endif.
Get the next child
X_NODE = x_node->get_first_child( ).
Recurse
while not X_NODE is initial.
perform GET_DATA tables GT_ITEM
using X_NODE
changing GV_HEADER.
X_NODE = x_node->get_next( ).
endwhile.
endform.
*sample xml file
<Name>Satya Mandiga</Name>
<Cardnum>234 234 234 234</Cardnum>
</Customer>
<ID>209</ID>
<Title>Duke: A Biography of the SAP Java Guru</Title>
<Quantity>1</Quantity>
<UnitPrice>Rs10.75</UnitPrice>
</Item>
<ID>208</ID>
<Title>100% Pure: Making Cross Platform Deployment a Reality</Title>
<Quantity>1</Quantity>
<UnitPrice>Rs10.75</UnitPrice>
</Item>
<ID>204</ID>
<Title>Making the Transition from C++ to the Java(tm)
*Language</Title>
<Quantity>1</Quantity>
<UnitPrice>Rs10.75</UnitPrice>
</Item>
<ID>202</ID>
<Title>Web Servers for Fun and Profit</Title>
<Quantity>1</Quantity>
<UnitPrice>Rs10.75</UnitPrice>
</Item>
<ID>210</ID>
<Title>I Think Not: Dukes Likeness to the Federation Insignia</Title>
<Quantity>1</Quantity>
<UnitPrice>Rs10.75</UnitPrice>
</Item>
</Manifest>
<Subtotal>Rs53.75</Subtotal>
<Tax>Rs4.43</Tax>
<Total>Rs58.18</Total>
</Receipt>
</Order>
reward the points -
Hi Friends,
See the followong code which converts xml data into itab.
*& Report ZTEST_XML1 *
REPORT ZTEST_XML1 .
*PURPOSE: This program transfers XML data into SAP internal table format
*The nodes in DOM can be stored as fields in SAP Internal table
type pool definitions
TYPE-POOLS: ixml. "iXML Library Types
type definitions
TYPES: BEGIN OF t_xml_line, "Structure for holding XML data
data(256) TYPE x,
END OF t_xml_line.
DATA: l_ixml TYPE REF TO if_ixml,
l_streamfactory TYPE REF TO if_ixml_stream_factory,
l_parser TYPE REF TO if_ixml_parser,
l_istream TYPE REF TO if_ixml_istream,
l_document TYPE REF TO if_ixml_document,
l_node TYPE REF TO if_ixml_node,
l_xmldata TYPE string.
DATA: l_elem TYPE REF TO if_ixml_element,
l_root_node TYPE REF TO if_ixml_node,
l_next_node TYPE REF TO if_ixml_node,
l_name TYPE string,
l_iterator TYPE REF TO if_ixml_node_iterator.
DATA: l_xml_table TYPE TABLE OF t_xml_line, " XML Table of the structure
*t_xml_line
l_xml_line TYPE t_xml_line, " Record of structure t_xml_line
l_xml_table_size TYPE i. " XML table size
DATA: l_filename TYPE string. " String to hold filename
data: begin of i_final occurs 0,
pnumber(20),
pname(50),
pdes(70),
end of i_final.
PARAMETERS: pa_file TYPE char1024 DEFAULT 'C:\product.xml'.
Validation of XML file: Only DTD included in XML document is supported
PARAMETERS: pa_val TYPE char1 AS CHECKBOX.
start of selection
START-OF-SELECTION.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
Wrap the table containing the file into a stream.
l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
size = l_xml_table_size ).
Creating a document
l_document = l_ixml->create_document( ).
Creating a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
Validate a document
IF pa_val = 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
ENDIF.
Parse the stream
IF l_parser->parse( ) <> 0.
IF l_parser->num_errors( ) <> 0.
DATA: parseerror TYPE REF TO if_ixml_parse_error,
str TYPE string,
i TYPE i,
count TYPE i,
index TYPE i.
count = l_parser->num_errors( ).
WRITE: count, ' parse errors have occured:'.
index = 0.
WHILE index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
WRITE: 'line: ', i.
i = parseerror->get_column( ).
WRITE: 'column: ', i.
str = parseerror->get_reason( ).
WRITE: str.
index = index + 1.
ENDWHILE.
ENDIF.
ENDIF.
Process the document
IF l_parser->is_dom_generating( ) EQ 'X'.
PERFORM process_dom USING l_document.
ENDIF.
*& Form get_xml_table
text
<--P_L_XML_TABLE_SIZE text
<--P_L_XML_TABLE text
FORM get_xml_table CHANGING p_l_xml_table_size
p_l_xml_table.
Local variable declarations
DATA: l_len TYPE i,
l_len2 TYPE i,
l_tab TYPE tsfixml,
l_content TYPE string,
l_str1 TYPE string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab TYPE TABLE OF string.
l_filename = pa_file.
Upload file from the client's workstation
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_filename
filetype = 'BIN'
IMPORTING
filelength = l_xml_table_size
CHANGING
data_tab = l_xml_table
EXCEPTIONS
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data replacement
= space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
ENDFORM. " get_xml_table
*& Form process_dom
text
-->P_L_DOCUMENT text
FORM process_dom USING document TYPE REF TO if_ixml_document.
DATA: node TYPE REF TO if_ixml_node,
iterator TYPE REF TO if_ixml_node_iterator,
nodemap TYPE REF TO if_ixml_named_node_map,
attr TYPE REF TO if_ixml_node,
name TYPE string,
prefix TYPE string,
value TYPE string,
indent TYPE i,
count TYPE i,
index TYPE i.
node ?= document.
CHECK NOT node IS INITIAL.
ULINE.
WRITE:/.
WRITE: /' DOM-TREE'.
WRITE: /.
IF node IS INITIAL.
EXIT.
ENDIF.
Create a node iterator
iterator = node->create_iterator( ).
Get current node
node = iterator->get_next( ).
Loop over all nodes
WHILE NOT node IS INITIAL.
indent = node->get_height( ) * 2.
indent = indent + 20.
CASE node->get_type( ).
WHEN if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
WRITE: / 'ELEMENT :'.
WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
IF NOT nodemap IS INITIAL.
attributes
count = nodemap->get_length( ).
DO count TIMES.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
WRITE: / 'ATTRIBUTE:'.
WRITE: AT indent name COLOR COL_HEADING INVERSE, '=',
value COLOR COL_TOTAL INVERSE.
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
text node
value = node->get_value( ).
WRITE: / 'VALUE :'.
WRITE: AT indent value COLOR COL_GROUP INVERSE.
ENDCASE.
Advance to next node
node = iterator->get_next( ).
ENDWHILE.
*delete adjacent duplicates from i_final.
*loop at i_final.
*write:/ i_final-pnumber,i_final-pname,i_final-pdes.
*endloop.
*if not i_final[] is initial.
*modify ztestproduct from table i_final.
*endif.
ENDFORM. " process_dom
in the above code at line no: 268 there is a method:
value = node->get_value( ).in which actual data from XML file is coming.
So the varibale "Value" contains the data.
see line no: 270:
WRITE: AT indent value COLOR COL_GROUP INVERSE.
what ever values i am getting here i want to append to a Internal table ...
Can any body tell me how to do that?
i am sure of reward points.Hai Ravi
REPORT abc.
DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
FIRST PHASE
FIRST PHASE
FIRST PHASE
Fetch Data
SELECT * FROM t001 INTO TABLE t001.
XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
Convert to TABLE
CALL FUNCTION 'HR_EFI_CONVERT_STRING_TO_TABLE'
EXPORTING
i_string = xml_out
i_tabline_length = 100
TABLES
et_table = itab.
Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:\xx.xml'
TABLES
data_tab = itab.
SECOND PHASE
SECOND PHASE
SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[].
Regards
Sreeni -
Hello folks,
I've been struggling and I need to figure out how to read a field from an XML field into ABAP. I'm writing this method and I need to call this field from my XML file. Can you guys please give me suggestions? Please advise. I will appreciate your time. Thanks in advance.
Ol.*& Report z_xit_xml_check
report z_xit_xml_check.
class cl_ixml definition load.
type-pools: ixml.
types: begin of t_xml_line,
data(256) type x,
end of t_xml_line,
begin of tsfixml,
data(1024) type c,
end of tsfixml.
data: l_ixml type ref to if_ixml,
l_streamfactory type ref to if_ixml_stream_factory,
l_parser type ref to if_ixml_parser,
l_istream type ref to if_ixml_istream,
l_document type ref to if_ixml_document,
l_node type ref to if_ixml_node,
l_xmldata type string.
data: l_elem type ref to if_ixml_element,
l_root_node type ref to if_ixml_node,
l_next_node type ref to if_ixml_node,
l_name type string,
l_iterator type ref to if_ixml_node_iterator.
data: l_xml_table type table of t_xml_line,
l_xml_line type t_xml_line,
l_xml_table_size type i.
data: l_filename type string.
parameters: pa_file type char1024 default
'd:\joao\desenvolvimentos\fi\fact\teste.xml'.
Validation of XML file: Only DTD included in xml document is supported
parameters: pa_val type char1 as checkbox.
start-of-selection.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
perform get_xml_table changing l_xml_table_size l_xml_table.
wrap the table containing the file into a stream
l_istream = l_streamfactory->create_istream_itable( table =
l_xml_table
size =
l_xml_table_size ).
Creating a document
l_document = l_ixml->create_document( ).
Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
Validate a document
if pa_val eq 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
endif.
Parse the stream
if l_parser->parse( ) ne 0.
if l_parser->num_errors( ) ne 0.
data: parseerror type ref to if_ixml_parse_error,
str type string,
i type i,
count type i,
index type i.
count = l_parser->num_errors( ).
write: count, ' parse errors have occured:'.
index = 0.
while index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
write: 'line: ', i.
i = parseerror->get_column( ).
write: 'column: ', i.
str = parseerror->get_reason( ).
write: str.
index = index + 1.
endwhile.
endif.
endif.
Process the document
if l_parser->is_dom_generating( ) eq 'X'.
perform process_dom using l_document.
endif.
*& Form get_xml_table
form get_xml_table changing l_xml_table_size type i
l_xml_table type standard table.
Local variable declaration
data: l_len type i,
l_len2 type i,
l_tab type tsfixml,
l_content type string,
l_str1 type string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab type table of string.
l_filename = pa_file.
upload a file from the client's workstation
call method cl_gui_frontend_services=>gui_upload
exporting
filename = l_filename
filetype = 'BIN'
importing
filelength = l_xml_table_size
changing
data_tab = l_xml_table
exceptions
others = 19.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
*replacement = space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab
*IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
endform. "get_xml_table
*& Form process_dom
form process_dom using document type ref to if_ixml_document.
data: node type ref to if_ixml_node,
iterator type ref to if_ixml_node_iterator,
nodemap type ref to if_ixml_named_node_map,
attr type ref to if_ixml_node,
name type string,
prefix type string,
value type string,
indent type i,
count type i,
index type i.
data: name2 type string,
name_root type string,
node_parent type ref to if_ixml_node,
node_root type ref to if_ixml_node,
num_children type i.
node ?= document.
check not node is initial.
uline.
write: /.
write: /' DOM-TREE'.
write: /.
if node is initial. exit. endif.
create a node iterator
iterator = node->create_iterator( ).
get current node
node = iterator->get_next( ).
loop over all nodes
while not node is initial.
indent = node->get_height( ) * 2.
indent = indent + 20.
num_children = node->num_children( ).
case node->get_type( ).
when if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
node_root = node->get_root( ).
name_root = node_root->get_name( ).
write: / 'ELEMENT :'.
write: at indent name color col_positive inverse.
write: 'NUM_CHILDREN:', num_children.
write: 'ROOT:', name_root.
node_parent = node->get_parent( ).
name2 = node_parent->get_name( ).
write: 'NAME2: ' , name2.
if not nodemap is initial.
attributes
count = nodemap->get_length( ).
do count times.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
write: / 'ATTRIBUTE:'.
write: at indent name color col_heading inverse, '=',
value color col_total inverse.
enddo.
endif.
when if_ixml_node=>co_node_text or
if_ixml_node=>co_node_cdata_section.
text node
value = node->get_value( ).
write: / 'VALUE :'.
mjprocha
node_parent = node->get_parent( ).
write: at indent value color col_group inverse.
name2 = node_parent->get_name( ).
write: 'NAME2: ' , name2.
endcase.
advance to next node
node = iterator->get_next( ).
endwhile.
endform. "process_dom -
Using importdata to import xml data into dynamic PDF form
Hi again,
Me and my colleagues have a problem using the importData service to import some xml data into an empty PDF form (represented as an XFA input variable).
In the server log I get the error that Only XDP data is supported for XFA forms, however I only have the xml data and not the entire xdp available.
Is this really not possible to to (like importing xml data to a form is possible in the Designer when creating forms).
I hope the scenario is understandable
Sincerely
Kim Christensen
Dafolo A/S
Denmark
PS: During the various projects I am working on I keep running into problems...however I am totally new to LiveCycle so I consider this very informative learning steps and appreciate all your help :-)Hi again,<br /><br />I have been experimenting a little with both the renderPDFForm and importData services. However I don't seem to be ble to make them work as I need them to.<br /><br />My scenario is simple, I have one (call it a template xdp/PDF form) and lots of data in xml files (around 1000), that I need to import into the template. Therefore I have set up a "Watched Folder" to take the xml as a document (I guess this is a requirement) and then I need either the renderPDF or importData services to import the xml data into the template.<br /><br />I would like to know how I should setup the services to make this work.<br /><br />When I try to use importdata I setup the following:<br /><br />PDF document: set to be the template i need to import the xml to)<br /><br />Input data: the document variable (an xml file) that is passed to the Watched Folder<br /><br />Data merged PDF: set to an out xfaform<br /><br />When I do this I get an Coercion error in the server log:<br /><br />2007-11-15 13:27:05,324 ERROR [com.adobe.workflow.AWS] stalling action-instance: 1506 with message: ALC-DSC-000-000: com.adobe.idp.dsc.DSCRuntimeException: Internal error.<br /> at com.adobe.idp.dsc.util.CoercionUtil.toDOMDocument(CoercionUtil.java:656)<br /> at com.adobe.idp.dsc.util.CoercionUtil.toType(CoercionUtil.java:878)<br /> at com.adobe.idp.dsc.util.CoercionUtil.toType(CoercionUtil.java:803)<br /> at com.adobe.workflow.datatype.runtime.support.AbstractDataTypeRuntimeHandler.coerceFrom(Abs tractDataTypeRuntimeHandler.java:64)<br /> at com.adobe.workflow.datatype.runtime.support.AbstractComplexDataTypeRuntimeHandler.getNode (AbstractComplexDataTypeRuntimeHandler.java:47)<br /> at com.adobe.workflow.dom.VariableElement.setBoundValue(VariableElement.java:93)<br /> at com.adobe.workflow.pat.service.PATExecutionContextImpl.setProcessDataValue(PATExecutionCo ntextImpl.java:729)<br /> at com.adobe.workflow.pat.service.PATExecutionContextImpl.setProcessDataWithExpression(PATEx ecutionContextImpl.java:335)<br /> at com.adobe.idp.workflow.dsc.service.SetValueService.execute(SetValueService.java:46)<br />...<br />Caused by: ALC-DSC-119-000: com.adobe.idp.dsc.util.InvalidCoercionException: Cannot coerce object: <document state="passive" senderVersion="3" persistent="false" senderPersistent="true" passivated="true" senderPassivated="true" deserialized="true" senderHostId="127.0.0.1/172.16.10.125" callbackId="0" senderCallbackId="7" callbackRef="null" isLocalizable="true" isTransactionBound="false" defaultDisposalTimeout="600" disposalTimeout="600" maxInlineSize="65536" defaultMaxInlineSize="65536" inlineSize="8039" contentType="application/xml" length="-1"><cacheId/><localBackendId/><globalBackendId/><senderLocalBackendId/><senderGl obalBackendId/><inline><?xml version="1.0" encoding="UTF-8"?><br /><form1><br /> <sub_BlanketTop /><br /> <sub_SubjectTop><br /> <f...</inline><senderPullServantJndiName>adobe/idp/DocumentPullServant/adobejb_server1</s enderPullServantJndiName><attributes file="c:\NCRConvert\ProcessForm\stage\Wx450d4b32843a0b0bcb8ef99e\NCR-00564_dXAE3soH.xml"/ ></document> of type: com.adobe.idp.Document to type: interface org.w3c.dom.Document<br /> at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)<br /> at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)<br /><br />However it is possible to manually import the xml data in Acrobat Professional without any problems.<br /><br />When I use the renderPDFForm with the following settings:<br /><br />Form to render: literal value that points to the template<br /><br />Form data: document variable from watched folder (xml)<br /><br />Content Root URI: repository://<br /><br />With these settings I also get a coercion error, however it does not seem to be exactly the same.<br /><br />Sincerely<br />Kim
-
How To Store XML Fragments Using Functions Such As XMLElement
Hi
Not sure what I am missing. I wish to store XML fragments in variables so can pass around and concatenate with other fragments to make final XML document. Even before attempting to concatenate XML fragments, I am struggling to store any XML fragment in a variable. I am trying to use simple functions such as XMLElement to generate XML so can store in variable. I have seen many examples of XMLElement in SQL select statement. Can XMLElement be used in plsql? XMLElement says it returns value of type XMLType. Functions such as XMLElement make generating XML easier than creating all tags manually.
Below is simple example that demonstrates what I would like to do. I would like to be able to pass the XML fragment as either XMLType or clob. I receive error saying PLS-00201: identifier 'XMLELEMENT' must be declared
declare
vTheData XMLType;
vTheDataClob clob;
begin
vTheData:= XMLelement("empno",'1234567');
vTheDataClob:= xmlelement("empno",'1234567').getclobval();
end;
Where as I can use below, but surely don't have to use select into from dual method. I just expect can use XMLElement function in plsql same as sql, such as most other functions eg length, rtrim etc.
declare
vTheData XMLType;
vTheDataClob clob;
begin
select xmlelement("empno",'1234567')
into vTheData
from dual;
select xmlelement("empno",'1234567').getclobval()
into vTheDataClob
from dual;
end;
Hope this makes sense.
ThanksHaving said that, is there a more elegant way to achieve below. That is populate two XML fragments and concatenate together.
Sure, why not just only one statement?
select XMLConcat(
XMLElement( ... )
, XMLElement( ... )
into vTheResult
from dual;
As a second question, is it better to build and pass XML fragments as XMLType or clob?
I would say stay with XMLType but it depends on your requirement.
I generally avoid passing around pieces of data, SQL/XML functions are powerful in the way they can be used with set operations, so using them in a piecewise approach kinda negates what they're for. -
TYPE003: Runtime Type Mismatch
A general question:
ODSI 10gR3
Has anyone seen the "TYPE003: Runtime Type Mismatch" error returned when you pass a variable through a function rather than a literal? The variable is the exact same value as the literal and I have casted all to a xs:double before passing through the "getReferencesByVersionID" function in code below.
=============================================================
(: Always tested with the same $VersionID and only 1 order in the database :)
for $Order in tns:getOrdersByVersionID($VersionID)
return
(: let $OrderNum := tns:getOrderNum(fn:data($Order/ns1:OrderNum)) :) (: Fail :)
let $OrderNum := xs:double(fn:data($Order/ns1:OrderNum)) (: Fail :)
(: let $OrderNum := xs:double(12001002) :) (: Success :)
let $References := tns:getReferencesByVersionID($VersionID, $OrderNum)
return
Returned XML snippet when run successfully:
<ns0:Order ns0:TransactionPurpose="ADD/UPDATE">
<ns0:ShipperRef>J10310ST12001002</ns0:ShipperRef>
<ns0:OrderNum>12001002</ns0:OrderNum> (: Populated by: "data($Order/ns1:OrderNum)". "ns0:OrderNum" defined as xs:double in schema. Note: same value as literal :)
<ns0:Comments/>
<ns0:OrderType>O</ns0:OrderType>
<ns0:Workflow>O</ns0:Workflow>
Returned Trace when not working:
com.bea.dsp.das.exception.DASException: weblogic.xml.query.exceptions.XQueryTypeException: {bea-err}TYPE003: Runtime Type Mismatch
at com.bea.dsp.das.ejb.EJBClient.invokeOperation(EJBClient.java:160)
at com.bea.dsp.das.DataAccessServiceImpl.invokeOperation(DataAccessServiceImpl.java:171)
at com.bea.dsp.das.DataAccessServiceImpl.invoke(DataAccessServiceImpl.java:122)
at com.bea.dsp.ide.xquery.views.test.QueryExecutor.invokeFunctionOrProcedure(QueryExecutor.java:113)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.getFunctionExecutionResult(XQueryTestView.java:1041)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.executeFunction(XQueryTestView.java:1176)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.widgetSelectedImpl(XQueryTestView.java:1866)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.access$300(XQueryTestView.java:174)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent$3.run(XQueryTestView.java:1594)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.widgetSelectedBusy(XQueryTestView.java:1597)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.widgetSelected(XQueryTestView.java:1560)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3687)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3298)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
The obvious answer is that "fn:data($Order/ns1:OrderNum)" does not equal "xs:double(12001002)" when passed through the " tns:getReferencesByVersionID()" function but it appears to be the same value.
This is happening in the Application layer so too much to include all the code. Thoughts/Comments on where to look or what I am missing?
Thanks
TomThanks Mike. No other web services... all physical ODSI to a single Oracle 11g denormalized table, selected several times to get different parts of the data (order header, shipping info, items, etc) and bubbled up through the layers via transformations finally getting into a single XML ORDER at the app layer.
I'm not a guru at reading traces but it appears numieric vs double issue?
The full stack trace:
weblogic.xml.query.exceptions.XQueryTypeException: {bea-err}TYPE003: Runtime Type Mismatch
at weblogic.xml.query.runtime.core.ExecutionWrapper.asXQueryException(ExecutionWrapper.java:165)
at weblogic.xml.query.runtime.core.ExecutionWrapper.fetchNext(ExecutionWrapper.java:94)
at weblogic.xml.query.iterators.GenericIterator.hasNext(GenericIterator.java:133)
at weblogic.xml.query.runtime.node.DeflateRec.fetchNext(DeflateRec.java:43)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at com.bea.ld.server.ResultPusher$ChunkyBinxmlChunker.nextChunk(ResultPusher.java:402)
at com.bea.ld.server.ResultPusher$AsyncChunkyBinxmlChunker.nextChunk(ResultPusher.java:520)
at com.bea.ld.server.ResultPusher$BinxmlChunker.next(ResultPusher.java:292)
at com.bea.ld.EJBRequestHandler$1.next(EJBRequestHandler.java:938)
at com.bea.ld.ServerBean.maybeStreamResult(ServerBean.java:97)
at com.bea.ld.ServerBean.executeOperationStreaming(ServerBean.java:86)
at com.bea.ld.Server_ydm4ie_EOImpl.executeOperationStreaming(Server_ydm4ie_EOImpl.java:72)
at com.bea.ld.Server_ydm4ie_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
java.lang.ClassCastException: weblogic.xml.query.tokens.basic.Basic_StringToken
at weblogic.xml.query.runtime.numeric.compare.DoubleEqual.compare(DoubleEqual.java:31)
at weblogic.xml.query.runtime.compare.ComparisonIterator.execute(ComparisonIterator.java:45)
at weblogic.xml.query.iterators.FunctionIterator.fetchNext(FunctionIterator.java:30)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.logic.BoolEffValue.exec(BoolEffValue.java:47)
at weblogic.xml.query.runtime.logic.BoolEffValue.execute(BoolEffValue.java:43)
at weblogic.xml.query.iterators.FunctionIterator.fetchNext(FunctionIterator.java:30)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.IfThenElse.fetchNext(IfThenElse.java:79)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.CountMapIterator.fetchNext(CountMapIterator.java:167)
at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
at weblogic.xml.query.runtime.constructor.SuperElementConstructor.getPhase2(SuperElementConstructor.java:388)
at weblogic.xml.query.runtime.constructor.PartMatElemConstructor.matEverything(PartMatElemConstructor.java:123)
at weblogic.xml.query.runtime.constructor.PartMatElemConstructor.fetchNext(PartMatElemConstructor.java:197)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.IfThenElse.fetchNext(IfThenElse.java:91)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.IfThenElse.fetchNext(IfThenElse.java:91)
at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
at weblogic.xml.query.runtime.navigation.ChildPath.fetchNext(ChildPath.java:221)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.iterators.BasicMaterializedTokenStream.next(BasicMaterializedTokenStream.java:109)
at weblogic.xml.query.iterators.BasicMaterializedTokenStream$MatStreamIterator.fetchNext(BasicMaterializedTokenStream.java:448)
at weblogic.xml.query.iterators.LegacyGenericIterator.next(LegacyGenericIterator.java:109)
at weblogic.xml.query.runtime.core.RTVariable.fetchNext(RTVariable.java:53)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.sequences.Exists.execute(Exists.java:37)
at weblogic.xml.query.iterators.FunctionIterator.fetchNext(FunctionIterator.java:30)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.IfThenElse.fetchNext(IfThenElse.java:79)
at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
at weblogic.xml.query.runtime.constructor.SuperElementConstructor.getPhase2(SuperElementConstructor.java:388)
at weblogic.xml.query.runtime.constructor.PartMatElemConstructor.matEverything(PartMatElemConstructor.java:123)
at weblogic.xml.query.runtime.constructor.PartMatElemConstructor.fetchNext(PartMatElemConstructor.java:197)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.iterators.BasicMaterializedTokenStream.next(BasicMaterializedTokenStream.java:109)
at weblogic.xml.query.iterators.BasicMaterializedTokenStream$MatStreamIterator.fetchNext(BasicMaterializedTokenStream.java:448)
at weblogic.xml.query.iterators.LegacyGenericIterator.next(LegacyGenericIterator.java:109)
at weblogic.xml.query.runtime.core.RTVariable.fetchNext(RTVariable.java:53)
at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
at weblogic.xml.query.runtime.navigation.ChildPath.fetchNext(ChildPath.java:221)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.sequences.Exists.execute(Exists.java:37)
at weblogic.xml.query.iterators.FunctionIterator.fetchNext(FunctionIterator.java:30)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.IfThenElse.fetchNext(IfThenElse.java:79)
at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
at weblogic.xml.query.runtime.constructor.SuperElementConstructor.buildPreserveModeTextNode(SuperElementConstructor.java:320)
at weblogic.xml.query.runtime.constructor.SuperElementConstructor.getPhase2(SuperElementConstructor.java:405)
at weblogic.xml.query.runtime.constructor.PartMatElemConstructor.matEverything(PartMatElemConstructor.java:123)
at weblogic.xml.query.runtime.constructor.PartMatElemConstructor.fetchNext(PartMatElemConstructor.java:197)
at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
at weblogic.xml.query.runtime.constructor.SuperElementConstructor.getPhase2(SuperElementConstructor.java:388)
at weblogic.xml.query.runtime.constructor.PartMatElemConstructor.fetchNext(PartMatElemConstructor.java:229)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.LetIterator.fetchNext(LetIterator.java:133)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.LetIterator.fetchNext(LetIterator.java:133)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.LetIterator.fetchNext(LetIterator.java:133)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.LetIterator.fetchNext(LetIterator.java:133)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.LetIterator.fetchNext(LetIterator.java:133)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.CountMapIterator.fetchNext(CountMapIterator.java:167)
at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
at weblogic.xml.query.runtime.constructor.SuperElementConstructor.getPhase2(SuperElementConstructor.java:388)
at weblogic.xml.query.runtime.constructor.PartMatElemConstructor.fetchNext(PartMatElemConstructor.java:229)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.debug.Trace.fetchNext(Trace.java:70)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.xdbc.iterators.ItemIterator.fetchNext(ItemIterator.java:86)
at weblogic.xml.query.iterators.LegacyGenericIterator.hasNext(LegacyGenericIterator.java:130)
at weblogic.xml.query.runtime.sequences.Subsequence.fetchNext(Subsequence.java:101)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.querycide.QueryAssassin.fetchNext(QueryAssassin.java:54)
at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:163)
at weblogic.xml.query.runtime.qname.InsertNamespaces.fetchNext(InsertNamespaces.java:237)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at weblogic.xml.query.runtime.core.ExecutionWrapper.fetchNext(ExecutionWrapper.java:88)
at weblogic.xml.query.iterators.GenericIterator.hasNext(GenericIterator.java:133)
at weblogic.xml.query.runtime.node.DeflateRec.fetchNext(DeflateRec.java:43)
at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:104)
at com.bea.ld.server.ResultPusher$ChunkyBinxmlChunker.nextChunk(ResultPusher.java:402)
at com.bea.ld.server.ResultPusher$AsyncChunkyBinxmlChunker.nextChunk(ResultPusher.java:520)
at com.bea.ld.server.ResultPusher$BinxmlChunker.next(ResultPusher.java:292)
at com.bea.ld.EJBRequestHandler$1.next(EJBRequestHandler.java:938)
at com.bea.ld.ServerBean.maybeStreamResult(ServerBean.java:97)
at com.bea.ld.ServerBean.executeOperationStreaming(ServerBean.java:86)
at com.bea.ld.Server_ydm4ie_EOImpl.executeOperationStreaming(Server_ydm4ie_EOImpl.java:72)
at com.bea.ld.Server_ydm4ie_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) -
I want to convert XML file into SAP Internal table
Hi Frndz,
My xml file is:
<?xml version="1.0" ?>
- <!-- Comments: START DATE :1/11/2002 11:26:14 PM
-->
- <!-- Comments: RFID Tags read by Mercury4 Copyright Praff@Anantara Solutions
-->
<RFIDs><ID>0x303030303030303035050000B5EC</ID><ID>0x300833B2DDD901403505000042E7</ID></RFIDs>
i want to take those 2 ID's in a internal table that id field is of 28 character type....
very urgent.
Thanks,
Arunprasad.Pclass cl_ixml definition load.
type-pools: ixml.
types: begin of t_xml_line,
data(256) type x,
end of t_xml_line,
begin of tsfixml,
data(1024) type c,
end of tsfixml.
data: l_ixml type ref to if_ixml,
l_streamfactory type ref to if_ixml_stream_factory,
l_parser type ref to if_ixml_parser,
l_istream type ref to if_ixml_istream,
l_document type ref to if_ixml_document,
l_node type ref to if_ixml_node,
l_xmldata type string.
data: l_elem type ref to if_ixml_element,
l_root_node type ref to if_ixml_node,
l_next_node type ref to if_ixml_node,
l_name type string,
l_iterator type ref to if_ixml_node_iterator.
data: l_xml_table type table of t_xml_line,
l_xml_line type t_xml_line,
l_xml_table_size type i.
data: l_filename type string.
parameters: pa_file type char1024 default
'C:\WINDOWS\Desktop\RFIDTags.xml'.
*Validation of XML file: Only DTD included in xml document is supported
parameters: pa_val type char1 as checkbox.
start-of-selection.
*Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
*Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
perform get_xml_table changing l_xml_table_size l_xml_table.
*wrap the table containing the file into a stream
l_istream = l_streamfactory->create_istream_itable( table = l_xml_table
size = l_xml_table_size ).
*Creating a document
l_document = l_ixml->create_document( ).
*Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
*Validate a document
if pa_val eq 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
endif.
*Parse the stream
if l_parser->parse( ) ne 0.
if l_parser->num_errors( ) ne 0.
data: parseerror type ref to if_ixml_parse_error,
str type string,
i type i,
count type i,
index type i.
count = l_parser->num_errors( ).
write: count, ' parse errors have occured:'.
index = 0.
while index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
write: 'line: ', i.
i = parseerror->get_column( ).
write: 'column: ', i.
str = parseerror->get_reason( ).
write: str.
index = index + 1.
endwhile.
endif.
endif.
*Process the document
if l_parser->is_dom_generating( ) eq 'X'.
perform process_dom using l_document.
endif.
*& Form get_xml_table
form get_xml_table changing l_xml_table_size type i
l_xml_table type standard table.
*Local variable declaration
data: l_len type i,
l_len2 type i,
l_tab type tsfixml,
l_content type string,
l_str1 type string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab type table of string.
l_filename = pa_file.
*upload a file from the client's workstation
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = l_filename
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = l_xml_table_size
HEADER =
TABLES
DATA_TAB = l_xml_table
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
replacement = space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab
IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
endform. "get_xml_table
*& Form process_dom
form process_dom using document type ref to if_ixml_document.
data: node type ref to if_ixml_node,
iterator type ref to if_ixml_node_iterator,
nodemap type ref to if_ixml_named_node_map,
attr type ref to if_ixml_node,
name type string,
prefix type string,
value type string,
indent type i,
count type i,
index type i.
data: name2 type string,
name_root type string,
node_parent type ref to if_ixml_node,
node_root type ref to if_ixml_node,
num_children type i.
node ?= document.
check not node is initial.
uline.
write: /.
write: /' DOM-TREE'.
write: /.
if node is initial. exit. endif.
create a node iterator
iterator = node->create_iterator( ).
get current node
node = iterator->get_next( ).
loop over all nodes
while not node is initial.
indent = node->get_height( ) * 2.
indent = indent + 20.
num_children = node->num_children( ).
case node->get_type( ).
when if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
node_root = node->get_root( ).
name_root = node_root->get_name( ).
write: / 'ELEMENT :'.
write: at indent name color col_positive inverse.
write: 'NUM_CHILDREN:', num_children.
write: 'ROOT:', name_root.
node_parent = node->get_parent( ).
name2 = node_parent->get_name( ).
write: 'NAME2: ' , name2.
if not nodemap is initial.
*attributes
count = nodemap->get_length( ).
do count times.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
write: / 'ATTRIBUTE:'.
write: at indent name color col_heading inverse, '=',
value color col_total inverse.
enddo.
endif.
when if_ixml_node=>co_node_text or
if_ixml_node=>co_node_cdata_section.
*text node
value = node->get_value( ).
write: / 'VALUE :'.
node_parent = node->get_parent( ).
write: at indent value color col_group inverse.
name2 = node_parent->get_name( ).
write: 'NAME2: ' , name2.
endcase.
*advance to next node
node = iterator->get_next( ).
endwhile.
endform. "process_dom
Thanks,
Arunprasad.P -
XSL Fragment into HTML via Client-Side Transform
I am designing a site for a school. I searched and found the
post here from July 25, and I have also read the Dreamweaver
help file till I'm blue in the face. They talk all around the
answer but never definitively say if it's possible to do this.
Dreamweaver help mentions:
-- Workflow for performting client-side xsl transformations
Do one of the following:
In your Dreamweaver site, create an entire XSLT page. See
Creating entire XSLT pages.
Convert an existing HTML page to an entire XSLT page. See
Converting HTML pages to XSLT pages.
All the online tutorials show server-side transforms but I'm
not skilled in that...nor do I know if the hosting entity will
provide that level of access to their .NET server.
---- ok. that's the background of the situation. Now to my
problem. ---
We plan to have two mutually exclusive areas on the home
page, such as news & events, that will be updated by a single
school employee. The plan is to create two XML text files that one
teacher can update.
The XMLfiles will be manually uploaded to the web site and
the home page will read that data into properly formatted
information on the home page. I would greatly prefer to keep the
entire process as a client-side procedure.
I have created and linked XSL fragments to the XML data.
If I try to copy and paste code from the XSL fragment into
the index HTML page, I get nothing.
Success comes only after converting the home page into an
XSLT 1.0 file using Dreamweaver and copying and pasting the code
fromt he XSL file into the newly created XSLT file.
Hence my questions:
1 Can I bring these XSL fragments into an HTML home page or
do I have to convert it to XSLT?
2. If I must convert the HTML file to an XSLT file, can
people still type the website address in as www dot site dot com
and the XSLT file will open without anyone knowing the difference?
3. Can I even do this with a client-side transform?
4. Is it possible for one page to reference two separate XSL
fragments pointing to the two separate respective XML files?
Thank you very much for your help.Hi Eric,
these are the cache control headers of the request that serves the XSLT:
GET http://www.carsten-leue.de/test/iframe_xslt/xslt.php HTTP/1.1
Accept: */*
Referer: http://www.carsten-leue.de/test/iframe_xslt/xslt.php
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: www.carsten-leue.de
DNT: 1
Connection: Keep-Alive
There does not seem to be a header involved that prevents caching.
You mention the "legacy ActiveX" control. In which sense is this control involved in the usecase? In my scenario I am pointing the browser to the XML document that has an associated stylesheet and the browser automatically executes the transform.
I am not explicitly triggering the transform via some script in the page.
Does the ActiveX control still play a role in this scenario?
Carsten -
Hopefully a quick one that I'm just missing.
I have a child table:
create table files (docid number(9), filename varchar2(200), filetype varchar2(30));
insert into files values (1, '1.pdf', 'primary');
insert into files values (2, '2.pdf', 'primary');
insert into files values (2, '3.pdf', 'secondary');
insert into files values (2, '4.pdf', 'tertiary');
insert into files values (2, '5.pdf', 'pending');
insert into files values (3, '6.pdf', 'secondary');
insert into files values (3, '7.pdf', 'secondary');What I need is an XML fragment to add to the parent document XML to indicate whether a document has a child filetype of some (but not all) of the permitted types.
The rules are:
if a 'primary' exists, create an element <orig>Y</orig>, otherwise create an element <orig>N</orig>
if a 'secondary' exists, create an element <alt>Y</alt>, otherwise create an element <alt>N</alt>
if a 'tertiary' exists, create an element <fin>Y</fin>, otherwise create an element <fin>N</fin>
if a 'pending' exists, do nothing
the result would be something similar to the following for a given docid:
docid 1 : <orig>Y</orig><alt>N</alt><fin>N</fin>
docid 2 : <orig>Y</orig><alt>Y</alt><fin>Y</fin>
docid 3 : <orig>N</orig><alt>Y</alt><fin>N</fin>I've got a brute force solution in hand, but I'm pretty sure there's a more elegant way.Hi,
Here's one way, if you want to create one fragment at a time for a given DOCID :
SQL> SELECT xmlagg(
2 case ftype
3 when 'primary' then xmlelement("orig", ftype_exists)
4 when 'secondary' then xmlelement("alt", ftype_exists)
5 when 'tertiary' then xmlelement("fin", ftype_exists)
6 end
7 ) as result
8 FROM (
9 SELECT t.column_value as ftype
10 , case when count(f.filetype) != 0 then 'Y' else 'N' end as ftype_exists
11 FROM files f
12 RIGHT OUTER JOIN
13 TABLE(
14 sys.odcivarchar2list( 'primary'
15 , 'secondary'
16 , 'tertiary' )
17 ) t
18 ON t.column_value = f.filetype
19 AND f.docid = 1
20 GROUP BY t.column_value
21 );
RESULT
<orig>Y</orig><alt>N</alt><fin>N</fin>
For multiple DOCID in the same query, a slight modification using a partitioned outer join :
SQL> SELECT docid
2 , xmlagg(
3 case ftype
4 when 'primary' then xmlelement("orig", ftype_exists)
5 when 'secondary' then xmlelement("alt", ftype_exists)
6 when 'tertiary' then xmlelement("fin", ftype_exists)
7 end
8 ) as result
9 FROM (
10 SELECT f.docid
11 , t.column_value as ftype
12 , case when count(f.filetype) != 0 then 'Y' else 'N' end as ftype_exists
13 FROM files f
14 PARTITION BY (f.docid)
15 RIGHT OUTER JOIN
16 TABLE(
17 sys.odcivarchar2list( 'primary'
18 , 'secondary'
19 , 'tertiary' )
20 ) t
21 ON t.column_value = f.filetype
22 GROUP BY f.docid, t.column_value
23 )
24 GROUP BY docid
25 ;
DOCID RESULT
1 <orig>Y</orig><fin>N</fin><alt>N</alt>
2 <orig>Y</orig><fin>Y</fin><alt>Y</alt>
3 <orig>N</orig><fin>N</fin><alt>Y</alt> -
Hello all,
I have generated an XML output through Smartforms. Now I need to load this file into DMS . Please let me know how I can achieve this.
Thanks,
Kalyancheck this code and use it...
REPORT Z_RMTIWARI_XML_TO_ABAP_46C .
Load iXML Lib.
type-pools: ixml.
class cl_ixml definition load.
data: G_IXML type ref to if_ixml.
data: STREAMFACTORY type ref to if_ixml_stream_factory.
data: ISTREAM type ref to if_ixml_istream.
data: DOCUMENT type ref to if_ixml_document.
data: PARSER type ref to if_ixml_parser.
data: LV_FILE_URL type rlgrap-filename.
You should provide the parameter for file name
LV_FILE_URL = 'C:input_xml.xml'.
types: begin of XML_LINE,
DATA(256) type x,
end of XML_LINE.
types: begin of TY_HEADER,
CUST_NAME(20) type c,
CARD_NO(20) type c,
TAX_AMOUNT(10) type c,
TOTAL_AMOUNT(10) type c,
end of TY_HEADER.
types: begin of TY_ITEM,
ITEM_NO(4) type n,
ITEM_ID(20) type c,
ITEM_TITLE(50) type c,
ITEM_QTY(10) type c,
ITEM_UPRICE(10) type c,
end of TY_ITEM.
data: GV_HEADER type TY_HEADER.
data: GT_ITEM type standard table of TY_ITEM with header line.
data: XML_TABLE type table of XML_LINE,
XML_TABLE_SIZE type i.
The next step is creating the main factory for the iXML library:
G_IXML = cl_ixml=>create( ).
Now Create Stream Factory
STREAMFACTORY = G_IXML->create_stream_factory( ).
upload a file from the client's workstation
call function 'WS_UPLOAD'
exporting
filename = LV_FILE_URL
filetype = 'BIN'
importing
filelength = XML_TABLE_SIZE
tables
data_tab = XML_TABLE
exceptions
others = 11.
wrap the table containing the file into a stream
ISTREAM = STREAMFACTORY->create_istream_itable( table = XML_TABLE
size = XML_TABLE_SIZE )
Get the file data as Stream
*istream = streamfactory->create_istream_uri( public_id = lv_file_url
system_id = lv_file_url ).
Create XML Document instance
DOCUMENT = G_IXML->create_document( ).
Create parser Object
PARSER = G_IXML->create_parser( stream_factory = STREAMFACTORY
ISTREAM = istream
DOCUMENT = document ).
Parse an XML document into a DOM tree
*parser->parse( ).
Parsing Error Processing
if PARSER->parse( ) ne 0.
if PARSER->num_errors( ) ne 0.
data: PARSEERROR type ref to if_ixml_parse_error,
STR type STRING,
I type i,
COUNT type I,
INDEX type i.
COUNT = PARSER->num_errors( ).
write: COUNT, ' parse errors have occured:'.
INDEX = 0.
while INDEX < COUNT.
PARSEERROR = PARSER->get_error( INDEX = index ).
I = PARSEERROR->get_line( ).
write: 'line: ', i.
I = PARSEERROR->get_column( ).
write: 'column: ', i.
STR = PARSEERROR->get_reason( ).
write: STR.
INDEX = index + 1.
endwhile.
endif.
endif.
Close the stream since it �s not needed anymore
call method ISTREAM->close( ).
clear ISTREAM.
Now try to make it look good
data : lv_size type sytabix,
lv_ret_code type sysubrc.
data: lo_xml_document type ref to cl_xml_document.
field-symbols: <fs_xml_data> type any table.
lo_xml_document = document.
call method lo_xml_document->get_as_table
importing
table = <fs_xml_data>
size = lv_size
retcode = lv_ret_code
*data: items type ref to if_ixml_node_collection.
*items = document->get_elements_by_tag_name( name = 'Item' ).
*data: iterator type ref to if_ixml_node_iterator,
node type ref to if_ixml_node.
*iterator = document->create_iterator( ).
*node = iterator->get_next( ).
*while not node is initial.
do something with the node
node = iterator->get_next( ).
*endwhile.
DATA : GV_NODE type ref to if_ixml_node.
DATA : GV_NODETEXT type STRING.
data: GV_FIRST_TIME.
GV_FIRST_TIME = 'X'.
GV_NODE = DOCUMENT.
GT_ITEM-item_no = 1.
perform GET_DATA tables GT_ITEM
using GV_NODE
changing GV_HEADER.
Last item is still not added.
append GT_ITEM.
write : GV_HEADER-cust_name,
GV_HEADER-card_no,
GV_HEADER-tax_amount,
GV_HEADER-total_amount.
loop at GT_ITEM.
write /:.
write : GT_ITEM-item_no,
GT_ITEM-item_id,
GT_ITEM-item_title,
GT_ITEM-item_qty,
GT_ITEM-item_uprice.
endloop.
FORM Get_data *
form get_data tables YT_ITEM structure GT_ITEM
using value(x_node) type ref to if_ixml_node
changing Y_HEADER type TY_HEADER.
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( ).
GV_NODETEXT = STRING.
when if_ixml_node=>co_node_text.
PTEXT ?= X_NODE->query_interface( IXML_IID_TEXT ).
if PTEXT->ws_only( ) is initial.
STRING = X_NODE->get_value( ).
case GV_NODETEXT.
when 'Customer'.
clear GV_HEADER.
when 'Name'.
move STRING to GV_HEADER-cust_name.
when 'Cardnum'.
move STRING to GV_HEADER-card_no.
when 'Tax'.
move STRING to GV_HEADER-tax_amount.
when 'Total'.
move STRING to GV_HEADER-total_amount.
Iteam details
when 'ID'.
move STRING to GT_ITEM-item_id.
when 'Title'.
move STRING to TEMP_STRING.
move TEMP_STRING to GT_ITEM-item_title.
when 'Quantity'.
move STRING to GT_ITEM-item_qty.
when 'UnitPrice'.
move STRING to GT_ITEM-item_uprice.
endcase.
endif.
endcase.
if GV_NODETEXT = 'Customer'.
clear GV_HEADER.
elseif GV_NODETEXT = 'Item'.
if GV_FIRST_TIME ne 'X'.
append GT_ITEM.
clear : gt_item.
GT_ITEM-item_no = gt_item-item_no + 1.
endif.
GV_FIRST_TIME = ' '.
endif.
Get the next child
X_NODE = x_node->get_first_child( ).
Recurse
while not X_NODE is initial.
perform GET_DATA tables GT_ITEM
using X_NODE
changing GV_HEADER.
X_NODE = x_node->get_next( ).
endwhile.
endform.
Maybe you are looking for
-
Is Apple not worried about the older models or what? My iPod was perfectly fine up until the 4.3.5 update. Now, I've lost about three or four $4.99+ games that I can't redownload for free, a whole music album, and I can't use wi-fi or bluetooth. I ca
-
Hello, lenovo community. First time posting here. I have recently been having issues with my T42, type 2373-8tu, where the screen will flicker and/or go blank, then the display will either look staticy (odd for an LCD) or it will just flash a bunch o
-
Need Profit Centre,WBS element fields in Customer/Vendor Line item display
Dear Experts, In Standard SAP we do not have the Profit Center, WBS Element in Customer / Vendor line item functionality. Now we need to develop user exit, when User try to post transactions like MIRO, F-02, FB01 system should ask the Profit Center f
-
ok so i just got a mac mini, i used my old ipod as a hard drive. i transfered songs over to new mac, and all my play counts are gone.... this majorly ***** because, some of my songs have 100 plus plays on them and my top 25 played songs are gone now.
-
Getting firstnames and surnames from group membership in AD
Morning guys.. I am trying to get a list of the firstname and surnames that are currently in a group on ad. I am currently using the following command but I want to tidy it up a bit. At the moment I am getting a table with a load of stuff I don't wan