Maintain attribute order in XML with a structure?
I'm using xmlParse() to read an XML file into a structure, and then process the structure (replace some of the XML attributes) and then write the structure back out as an XML file. The problem is that I loose the original ordering of XML attrbutes when I convert to a structure, and instead end up with a new attribute order for each element that is alphabetical.
In otherwords: <element c="text" d="text" a="text" />
gets rewritten as: <element a="text" c="text" d="text" />
which is a problem for this application.
Is there a way to work with XML in CF but maintain attribute ordering (LinkedHashMap instead of a structure, maybe)?
Thanks.
Walter
but using ColdFusion to process XML in this way is making a pretty big change in the XML structure.
No, it's not changing the structure in any meaningful way: the attribute ordering isn't meaningful in XML, so if the order of them changes, then that's not a meaningful change. In any way that XML should be used, it doesn't matter.
When CF reads an string (like file contents) and parses it as XML, it needs to create an XML object; that XML object will adhere to the rules of XML; one of which is "atribute order has no significance", so it will not (and ought not) bother to "remember" the order that the attributes were in in the original string. When one converts that object back into a string, some sort of ordering needs to be used to write them back, and CF seems to arbitrarily use alphabetical order. But it cannot refer back to information that it doesn't have (the original ordering), so the original ordering can't be preserved.
There's nothing unreasonable or that shouldn't be expected in this process, unfortunately (for you, I mean).
Adam
Similar Messages
-
How to create a attribute to context node with the structure that is in DDIC
Hi,
I have created a 3 value attributes while creating a view.
now i have changed the name of the one of the field in my own database table.
now the problem is, when i open the webui and try to insert a row. i am getting error like "there is no field with that name(previous name) in collection".
that is not showing the new name that i have changed. so i deleted the attribute from my view and tried to add the attribute again. and while adding a single attribute it is not taking the ddic structure. and one more problem is, when i open the ui it is showing an error like " the attribute BaseEntityName is not defined or is still initial "
someone help me how to add the one more attribute from the same structure & how to provide BaseEntityName.
Regards,
HarryHi Harry,
If my understanding is correct you have added a attribute with name "ZX" and now you have changed the name of the field to "ZZX" and when you try to add the attribute it gives an error.
In this case, if you are trying to add a attribute with the same name as you have used before. it will not allow so better to use a new name.
If the attribute is there and if you are not able to get or set the value of it, Please change the attribute name in the getter and setter methods in the set and get property method call, because by default SAP generates a hard coded text for your attribute name in the methods and if you change the name of the field this will not change.
Thanks,
Ashok N. -
How to read xml with deep structure into intarnal table.
Hi,
Could you pls any body provide xslt code for deep structure convert into internal table.
sample xml file:
- <ns0:CREATIONOFCONTRACT xmlns:ns0="http://BPCreationXSD.CreationOfContract">
- <CREATIONOFCONTRACTDATA>
<RequestType>L0011</RequestType>
<ApplicationId>AN-12</ApplicationId>
<LoanId>QO-22</LoanId>
- <Borrowerguarantorinfo>
<Borrowerbpno>101020</Borrowerbpno>
<Co-borrower1BPNo>101021</Co-borrower1BPNo>
<Co-borrower2BPNo>101022</Co-borrower2BPNo>
<Guarantor1BPNo>101023</Guarantor1BPNo>
<Guarantor2BPNo>101024</Guarantor2BPNo>
<Branch>New Delhi</Branch>
</Borrowerguarantorinfo>
- <Loaninfo>
<Applicationtype>Fresh</Applicationtype>
<Purposeofloan>Home Purchase</Purposeofloan>
<Securedunsecuredflag>Secured</Securedunsecuredflag>
<Loantype>HL with MRTA</Loantype>
<Loancurrency>INR</Loancurrency>
<Loanproduct>MaxiHome Loan Package</Loanproduct>
<Loanscheme>MaxiHome ZEC</Loanscheme>
<Loanamount>1500000.00</Loanamount>
<Loantenure>60</Loantenure>
<Tiered>No</Tiered>
</Loaninfo>
<Periodfrom>01/07/2009</Periodfrom>
<Periodto>16/09/2019</Periodto>
<RateType>Fixed</RateType>
<Ratecode>10.25</Ratecode>
</CREATIONOFCONTRACTDATA>
</ns0:CREATIONOFCONTRACT>Hi Ramesh,
Thanks for the info,but I found lot of tables unfortunately I am not getting the value for radio buttons. Also I found a FM FIELD_SELECTION_CUSTOMIZE , IMPORT_DYNPRO etc which will call that screen based on profile but it will not store data any where. I found several tables like TCATS, TFAWC, TFAWF, TFAWT etc.But I am not getting the value for raduio buttons.
Thanks & Regards,
Nagaraj Kalbavi -
XML with DefaultTreeModel structure
I�m developing an application which uses DefaultTreeModel as one of its major structure...
may I use a XML file as persistence ? May I map directly between the TreeModel and a XML file ?
Actually people around here cited Castor as the solution, but I can�t find in the castor documentation about trees mapping, just Vector, Hashtable and arrays...I�m thinking like this way:
the XML is a tree structure...
the TreeModel is obviously a tree structure...
then, I should be able to create a Java DefaultTreeModel which reflects the XML file contents..
I�m reading the SUN tutorial ... -
Handling XMLs with unknown structures.
Hello Experts,
I have to build a generic interface RFC -> PI -> JMS, which will receive XML structure as a string in import parameter of RFC.
Then I need to convert this string to XML, add digital signatures and then output the signed payload to JMS Queues.
I have been looking at SDN posts and found that XSLT can be used to convert string to XML. But the catch is I am not aware of the XML structures that will be sent in as a string. So how can I handle these unknown structures? Or what should be the structure of the target Interface for XSLT mapping??
Any inputs on this will be of great help.
Kind Regards,
PIQueries_2010If you dont want the target structure to be validated XSLT/java mapping is the way to go as pointed out by MIchal.
If you use the new feature, I believe it will validate the target structure.
@Michal,
Just a quick clarification, when we use java/xslt mapping to skip target message validation in PI 7.1 is it mandatory to have the operation name exactly same as Service Interface name? I recently ran into an issue where the Service interface name was different from the operation name and the Java mapping was giving an error saying "Unable to validate root element" or something similar (Ofcourse, the content was binary file and hence java mapping to skip the target structure validation).
Thanks
Jai -
How to use STRANS to translate XML to ABAP with deep structure
every experts, I want to use Tcode: STRANS to translate XML to ABAP, But it does not work well,
here is XML code,I want to translate this XML into an an Inter table gt_orders with deep structure of oeb, and colum oeb is also and intertable,how can I do this.
<?xml version="1.0" encoding="gb2312" ?><axmt410><ObjectID>setSalesOrder</ObjectID><azp01>000000</azp01><oea00>1</oea00><ta_oeaecn>SO-140227-3041</ta_oeaecn><oea03>25325017</oea03><oea02>2014-02-27 17:44:44.0</oea02><ta_oea002>2763.0</ta_oea002><ta_oea001>0.0</ta_oea001><oea14></oea14><oea15>25325017</oea15><oea23>RMB</oea23><oeaconf>S3</oeaconf><oea10></oea10><oeaud01>null</oeaud01><ta_oea007></ta_oea007><oea25>101</oea25><ta_oea008>0</ta_oea008><ta_oea009>null</ta_oea009><oeauser>Hanjingya</oeauser><ta_oeanday>2014-02-27 17:44:44.991</ta_oeanday><ta_oeamday>2014-02-28 08:30:14.866</ta_oeamday><ta_oeacday>2014-02-28 08:30:14.866</ta_oeacday><oeaud02>0</oeaud02><ta_oea030>null</ta_oea030><oeb><oeb03>1</oeb03><oeb04>7400208249</oeb04><oeb05>PCS</oeb05><oeb17>921.0</oeb17><oeb13>921.0</oeb13><oeb15></oeb15><oeb12>5</oeb12><oeb09>990001</oeb09><ta_oeb001></ta_oeb001><ta_oeb002>Yunnan</ta_oeb002><ta_oeb003>address1</ta_oeb003><ta_oeb004>zhangdagui、zhanglan</ta_oeb004><ta_oeb005>15974749998、15987782008</ta_oeb005><ta_oeb006>address and street</ta_oeb006><oebud01></oebud01></oeb><oeb><oeb03>2</oeb03><oeb04>7400208250</oeb04><oeb05>PCS</oeb05><oeb17>921.0</oeb17><oeb13>921.0</oeb13><oeb15></oeb15><oeb12>5</oeb12><oeb09>990001</oeb09><ta_oeb001></ta_oeb001><ta_oeb002>Yunnan</ta_oeb002><ta_oeb003>address2</ta_oeb003><ta_oeb004>zhangdagui、chenlan</ta_oeb004><ta_oeb005>15974749998、15987782008</ta_oeb005><ta_oeb006>address and street</ta_oeb006><oebud01></oebud01></oeb></axmt410>
I write these codes in SAP XSLT editor
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
<xsl:strip-space elements="*"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<ORDERS>
<xsl:apply-templates select="//axmt410"/>
</ORDERS>
</asx:values>
</asx:abap>
</xsl:template>
<xsl:template match="axmt410">
<OBJECTID>
<xsl:value-of select="ObjectID"/>
</OBJECTID>
<AZP01>
<xsl:value-of select="azp01"/>
</AZP01>
<OEA00>
<xsl:value-of select="oea00"/>
</OEA00>
<TA_OEAECN>
<xsl:value-of select="ta_oeaecn"/>
</TA_OEAECN>
<OEA03>
<xsl:value-of select="oea03"/>
</OEA03>
<OEA05>
<xsl:value-of select="oea05"/>
</OEA05>
<OEA02>
<xsl:value-of select="oea02"/>
</OEA02>
<TA_OEA002>
<xsl:value-of select="ta_oea002"/>
</TA_OEA002>
<TA_OEA001>
<xsl:value-of select="ta_oea001"/>
</TA_OEA001>
<OEA14>
<xsl:value-of select="ora14"/>
</OEA14>
<OEA15>
<xsl:value-of select="ora15"/>
</OEA15>
<OEA23>
<xsl:value-of select="ora23"/>
</OEA23>
<OEACONF>
<xsl:value-of select="oeaconf"/>
</OEACONF>
<OEA10>
<xsl:value-of select="ora10"/>
</OEA10>
<OEAUD01>
<xsl:value-of select="oeaud01"/>
</OEAUD01>
<TA_OEA007>
<xsl:value-of select="ta_oea007"/>
</TA_OEA007>
<OEA25>
<xsl:value-of select="ora25"/>
</OEA25>
<TA_OEA008>
<xsl:value-of select="ta_oea008"/>
</TA_OEA008>
<TA_OEA009>
<xsl:value-of select="ta_oea009"/>
</TA_OEA009>
<TA_OEA013>
<xsl:value-of select="ta_oea013"/>
</TA_OEA013>
<TA_OEA014>
<xsl:value-of select="ta_oea014"/>
</TA_OEA014>
<TA_OEA015>
<xsl:value-of select="ta_oea015"/>
</TA_OEA015>
<TA_OEA016>
<xsl:value-of select="ta_oea016"/>
</TA_OEA016>
<TA_OEA017>
<xsl:value-of select="ta_oea017"/>
</TA_OEA017>
<TA_OEA018>
<xsl:value-of select="ta_oea018"/>
</TA_OEA018>
<TA_OEA019>
<xsl:value-of select="ta_oea019"/>
</TA_OEA019>
<TA_OEA020>
<xsl:value-of select="ta_oea020"/>
</TA_OEA020>
<TA_OEA021>
<xsl:value-of select="ta_oea021"/>
</TA_OEA021>
<TA_OEA022>
<xsl:value-of select="ta_oea022"/>
</TA_OEA022>
<TA_OEA028>
<xsl:value-of select="ta_oea028"/>
</TA_OEA028>
<OEAUSER>
<xsl:value-of select="oeauser"/>
</OEAUSER>
<TA_OEANDAY>
<xsl:value-of select="ta_oeanday"/>
</TA_OEANDAY>
<TA_OEAMDAY>
<xsl:value-of select="ta_oeamday"/>
</TA_OEAMDAY>
<TA_OEACDAY>
<xsl:value-of select="ta_oeacday"/>
</TA_OEACDAY>
<OEAUD02>
<xsl:value-of select="oeaud02"/>
</OEAUD02>
<TA_OEA030>
<xsl:value-of select="ta_oea030"/>
</TA_OEA030>
<OEB>
<xsl:for-each select="oeb">
<OEB03>
<xsl:value-of select="oeb03"/>
</OEB03>
<OEB04>
<xsl:value-of select="oeb04"/>
</OEB04>
<OEB05>
<xsl:value-of select="oeb05"/>
</OEB05>
<OEB17>
<xsl:value-of select="oeb17"/>
</OEB17>
<OEB13>
<xsl:value-of select="oeb13"/>
</OEB13>
<OEB15>
<xsl:value-of select="oeb15"/>
</OEB15>
<OEB12>
<xsl:value-of select="oeb12"/>
</OEB12>
<OEB09>
<xsl:value-of select="oeb09"/>
</OEB09>
<TA_OEB001>
<xsl:value-of select="ta_oeb001"/>
</TA_OEB001>
<TA_OEB002>
<xsl:value-of select="ta_oeb002"/>
</TA_OEB002>
<TA_OEB003>
<xsl:value-of select="ta_oeb003"/>
</TA_OEB003>
<TA_OEB004>
<xsl:value-of select="ta_oeb004"/>
</TA_OEB004>
<TA_OEB005>
<xsl:value-of select="ta_oeb005"/>
</TA_OEB005>
<TA_OEB006>
<xsl:value-of select="ta_oeb006"/>
</TA_OEB006>
<OEBUD01>
<xsl:value-of select="oebud01"/>
</OEBUD01>
</xsl:for-each>
</OEB>
</xsl:template>
</xsl:transform>
and I use below ABAP program for a test, but the items from XML can not translate into Interner table gt_orders-oeb[]
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\temp\order02.xml'.
* This is the structure for the data from the XML file
TYPES:
BEGIN OF typ_s_oeb,
oeb03 TYPE string, "
oeb04 TYPE string, "
oeb05 TYPE string, "
oeb17 TYPE string, "
oeb13 TYPE string,
oeb15 TYPE string,
oeb12 TYPE string, "
oeb09 TYPE string, "
ta_oeb001 TYPE string, "
ta_oeb002 TYPE string, "
ta_oeb003 TYPE string, "
ta_oeb004 TYPE string, "
ta_oeb005 TYPE string, "
ta_oeb006 TYPE string, "
ta_oeb013 TYPE string, "
ta_oeb014 TYPE string, "
ta_oeb015 TYPE string, "
ta_oeb016 TYPE string, "
ta_oeb017 TYPE string, "
ta_oeb018 TYPE string, "
ta_oeb019 TYPE string, "
ta_oeb020 TYPE string, "
ta_oeb021 TYPE string, "
ta_oeb022 TYPE string, "
oebud01 TYPE string, "
END OF typ_s_oeb.
TYPES: typ_t_oeb TYPE TABLE OF typ_s_oeb WITH KEY oeb03.
TYPES:
BEGIN OF typ_s_order,
objectid TYPE string, "
azp01 TYPE string, "
oea00 TYPE string, "
ta_oeaecn TYPE string, "
oea03 TYPE string, "
oea02 TYPE string, "
ta_oea002 TYPE string, "
ta_oea001 TYPE string, "
oea14 TYPE string, "
oea15 TYPE string,
oea23 TYPE string, "
oeaconf TYPE string, "
oea10 TYPE string, "
oeaud01 TYPE string, "
ta_oea007 TYPE string, "
oea25 TYPE string, "
ta_oea008 TYPE string, "
ta_oea009 TYPE string, "
oeauser TYPE string, "
ta_oeanday TYPE string, "
ta_oeamday TYPE string, "
ta_oeacday TYPE string, "
oeaud02 TYPE string, "
ta_oea030 TYPE string, "
ta_oea013 TYPE string,
ta_oea014 TYPE string,
ta_oea015 TYPE string,
ta_oea016 TYPE string,
ta_oea017 TYPE string,
ta_oea018 TYPE string,
ta_oea019 TYPE string,
ta_oea020 TYPE string,
ta_oea021 TYPE string,
ta_oea022 TYPE string,
ta_oea025 TYPE string,
oeb TYPE typ_t_oeb,
END OF typ_s_order.
* Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048,
gs_itab LIKE LINE OF gt_itab.
* Table and work ares for the data from the XML file
DATA: gt_orders TYPE STANDARD TABLE OF typ_s_order,
gs_orders TYPE typ_s_order.
* Result table that contains references
* of the internal tables to be filled
DATA: gt_result_xml TYPE abap_trans_resbind_tab,
gs_result_xml TYPE abap_trans_resbind.
* For error handling
DATA: gs_rif_ex TYPE REF TO cx_root,
gs_var_text TYPE string.
* Get the XML file from your client
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gs_file
CHANGING
data_tab = gt_itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
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.
* Fill the result table with a reference to the data table.
* Within the XSLT stylesheet, the data table can be accessed with
* "IPERSON".
GET REFERENCE OF gt_orders INTO gs_result_xml-value.
gs_result_xml-name = 'ORDERS'.
APPEND gs_result_xml TO gt_result_xml.
* Perform the XSLT styleshee
TRY.
CALL TRANSFORMATION zfx_so_xml_to_abap
SOURCE XML gt_itab
RESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).
MESSAGE gs_var_text TYPE 'S'.
ENDTRY.
LOOP AT gt_orders INTO gs_orders.
ENDLOOP.The simplest way seems to me is to use a XSL file for that. The <xsl:output> attributes doctype-system and doctype-public generate the DTD declaration <!DOCTYPE YOUR_ROOT SYSTEM "yourDTDfile.dtd"> and <!DOCTYPE YOUR_ROOT PUBLIC "yourDTDfile.dtd">, respectively.
When calling transformerInstance.transform() the XSLT processor performs the identity transformation - it just copies elements, attributes, content, processing instructions and comments to the result stream.
If you're using an xsl file for your transformation already, simply add <xsl:output doctype-system="yourDTDfile.dtd"/> to your existing XSL file.
If you're only using the identity transformation you'd need to change the line of code where you obtain the transformer instance from the TransformerFactory to:
t_factory.newTransformer(new StreamSource("test.xsl"));
and use this as test.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output doctype-system="yourDTDfile.dtd"/>
<!-- this is the identity transformation -->
<xsl:template match="*|@*|comment()|processing-instruction()|text()">
<xsl:copy>
<xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>Good luck. -
Parse and output XML document while preserving attribute order
QUESTION: How can I take in an element with attributes from an XML and output the same element and attributes while preserving the order of those attributes?
The following code will parse and XML document and generate (practically) unchanged output. However, all attributes are ordered a-z
Example: The following element
<work_item_type work_item_db_site="0000000000000000" work_item_db_id="0" work_item_type_code="3" user_tag_ident="Step" name="Work Step" gmt_last_updated="2008-12-31T18:00:00.000000000" last_upd_db_site="0000000000000000" last_upd_db_id="0" rstat_type_code="1">
</work_item_type>is output as:
<work_item_type gmt_last_updated="2008-12-31T18:00:00.000000000" last_upd_db_id="0" last_upd_db_site="0000000000000000" name="Work Step" rstat_type_code="1" user_tag_ident="Step" work_item_db_id="0" work_item_db_site="0000000000000000" work_item_type_code="3">
</work_item_type>As you may notice, there is no difference in these besides order of the attributes!
I am convened that the problem is not in the stylesheet.xslt but if you are not then it is posted bellow.
Please, someone help me out with this! I have a feeling the solution is simple
The following take the XML from source.xml and outputs it to DEST_filename with attributes in a-z order
Code:
private void OutputFile(String DEST_filename, String style_filename){
//StreamSource stylesheet = new StreamSource(style_filename);
try{
File dest_file = new File(DEST_filename);
if(!dest_file.exists())
dest_file.createNewFile();
TransformerFactory tranFactory = TransformerFactory.newInstance();
Transformer aTransformer = tranFactory.newTransformer();
aTransformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
Source src = new DOMSource("source.xml");
Result dest = new StreamResult(dest_file);
aTransformer.transform(src, dest);
System.out.println("Finished");
catch(Exception e){
System.err.print(e);
System.exit(-1);
}You can't. The reason is, the XML Recommendation explicitly says the order of attributes is not significant. Therefore conforming XML serializers won't treat it as if it were significant.
If you have an environment where you think that the order of attributes is significant, your first step should be to reconsider. Possibly it isn't really significant and you are over-reaching in some way. Or possibly someone writing requirements is ignorant of this fact and the requirement can be discarded.
Or possibly your output is being given to somebody else who has a defective parser which expects the attributes to be in a particular order. You could quote the XML Recommendation to those people but often XML bozos are resistant to change. If you're stuck writing for that parser then you'll have to apply some non-XML processing to your output to fix it up on their behalf. -
XML import for repetition, is repitition with this structure possible
If it is possible, what does the XML and or template structure have to look like, in order to support repeating sections of
1. Chapter name (as a text)
2. Table
1. Chapter name
2. Table
1. Chapter name
2. Table
and so on...
Everything should be inside a text frame, in order to let the paragraph style of "Chapter name" always begin a new page. The text container is mapped to the xml element called "grp" in the example below.
I've imported in numerous ways with varying degrees of correctness, so if there is anyone that knows what I mean and how to tackle the problem, I would be very glad. I can work around the XML and the document in almost any way...
I only get it to work if there are sufficient number of chapternames and tables put out on the body page from start. I would like InDesign to create copies of the "template"...
But having just one "template" out on the body page, I get a result like this in the structure (and just the first one is mapped to the body page template, as you can see – the rest of them being empty unmapped XML brackets):
Thanks,
AndreasI made a layout on the first body page, and then I imported into that.
Err, you mean a text frame, not a layout, right? OK, I haven't played with it that way, I'll take a look at it tomorrow (might be a while) -- if no one else ha solved it first.
(The tables are not visible in the structure, howcome?)
I believe that once a table is converted from an XML table into an InDesign table, it is no longer visible as a distinct XML object, just like two letters in a word are not visible in the structure. (I could be wrong on this).
Yes, I used CALS tables. Why? Because it was the default. I made a layout like you described and exported it to XML, cleaned up the XML,
and reimported it for my test. CALS was the default checkbox, so I went with it. I don't think it has naything to do with the structure question.
I didn't use cals tables in my own XML file, but ordinary ones, mapped by column.
Aren't those more annoying to use?
Anyhow:
... but the repetition doing it my way does not work – as it does in your sample (and for me too, trying it), dragging the structure out onto the page.
So, is dragging it a good solution for you? Is your problem solved? Or does that not meet your needs? -
Hello
I've got a table XYZ with the fields ABC and DEF. I want Oracle XE database to give me the following XML back:
<ROWSET>
<ROW ABC="..." DEF="..."/>
<ROW ABC="..." DEF="..."/>
</ROWSET>
the fields as attributes. I know only how to get XML with elements but I need xml attributes. Does anybody know how this works with ODP.NET? I use the XmlCommandType property, r=ExecuteXmlReader() function and "doc.load(r)". In the past I got XML with attributes using Oracle9i R2, OO4O and MS Visual Basic 6. I set a property for each column.
Regards
Marcus Warm
(Germany)
[Oracle 10g Express Edition R2, Visual Studio 2005 VB, ADO.NET 2.0, Windows
XP]
<<also posted in de.comp.datenbanken.misc>>Hi
In this case you have to change your Source structure and map the attrbute values to target and in receiver channel you can perform your content conversion.
Regards
Ramg
Edited by: Ramkumar Ganesh on Apr 28, 2010 11:09 PM -
Process XML attributes of all tables in a structured document
Hi all,
I try to process the XML attributes of all tables in a structured document.
When I use SelectedTbl everything works fine for the selected table and the attributes of the tabelle Element are written correctly to the Console.
doc = app.ActiveDoc;
table = doc.SelectedTbl;
if (table.TblElement)
Console('Elementname: ' + table.TblElement.ElementDef.Name);
tblEle = table.Element;
attrs = tblEle.GetAttributes();
for (i = 0; i < attrs.len; i++) {
aName = attrs[i].name;
aWert = attrs[i].values;
Console( " " + aName + " " + aWert);
However when I use GetText(Constants.FTI_TblAnchor) to walk through all tables of the documens neither ElementDef.Name nor Attributes are processed.
var flow = doc.FirstFlowInDoc;
var textItems = flow.GetText(Constants.FTI_TblAnchor);
while(iTab<textItems.length) {
table = textItems[iTab].obj;
if (table.TblElement)
Console('Elementname: ' + table.TblElement.ElementDef.Name);
tblEle = table.Element;
attrs = tblEle.GetAttributes();
for (i = 0; i < attrs.len; i++) {
aName = attrs[i].name;
aWert = attrs[i].values;
Console( " " + aName + " " + aWert);
Any Suggestions?
Yours
WolfgangYou'll probably want all the tables from the main flow. Try
var flow = doc.MainFlowInDoc;
Kind regards
JoH -
How to convert an xml to another Xml with a different structure...
hi
i have an xml which should be converted to a standard xml with an entirely different structure(Different elements)....can this be done with xml,xsl alone or do we need to write an java class along with them...if there are any examples..it would be of great help...plz help me out....as this is a work stopper...
given below is the kind i have
<hotelinfo>
<hotelname>RADISSON HOTEL CHENNAI </hotelname>
<address>355 C Gst Road St Thomas Mount Chennai1 600016IN</address> <price>90.00 - 150.00</price>
<distance>2 (W)</distance>
</hotelinfo>
i need to convert it into
<propertyName>RADISSON HOTEL CHENNAI </propertyName>
<address>
<addressLine>355 C Gst Road St Thomas Mount</addressLine>
<CityName>Chennai</CityName>
<PostalCode>600 001</PostalCode>
<StateName>TamilNadu</StateName>
<CountryName>India</CountryName>
</address>
thanks in advanceOk here is the code...
package mypack;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
* @author SM23772
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
public class Roopa {
public static void main(String[] args) {
File docFile = new File("Roopa.xml");
Document doc = null;
Document newDoc = null;
String hname = null, task = null;
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(docFile); //parsing Roopa.xml
newDoc = db.newDocument(); //Created New document Object for new xml
hname = doc.getElementsByTagName("hotelname").item(0)
.getFirstChild().getNodeValue();
task = doc.getElementsByTagName("task").item(0).getFirstChild()
.getNodeValue();
Node rootNode = newDoc.createElement("property-info"); //creating root node;
Node pp = newDoc.createElement("name"); //creating a node called name
Node taskNode = newDoc.createElement("task"); //creating a node called task
pp.appendChild(newDoc.createTextNode(hname)); //appending a text node inisde name
taskNode.appendChild(newDoc.createTextNode(task)); //appending the text node inside task
rootNode.appendChild(pp); //asppending the nodes inside the root node
rootNode.appendChild(taskNode);
newDoc.appendChild(rootNode); //appending the root node to the document
writeXmlFile(newDoc, "Dest.xml"); //function called to write the document to Dest.xml
} catch (Exception e) {
System.out.println(e);
public static void writeXmlFile(Document doc, String filename) {
try {
// Prepare the DOM document for writing
Source source = new DOMSource(doc);
// Prepare the output file
File file = new File(filename);
Result result = new StreamResult(file);
// Write the DOM document to the file
Transformer xformer = TransformerFactory.newInstance()
.newTransformer();
xformer.transform(source, result);
} catch (TransformerConfigurationException e) {
} catch (TransformerException e) {
The xml files:
roopa.xml:
<hotel>
<hotelname>RADISSON HOTEL CHENNAI</hotelname>
<more-info><task>give treate to shanu</task></more-info>
</hotel>
Dest.xml
<?xml version="1.0" encoding="UTF-8"?>
<property-info><name>RADISSON HOTEL CHENNAI</name><task>give treate to shanu</task></property-info>Please go through the code.. if u have any more concerns do let me know................
cheers
Shanu -
Ordering of xml group elements
Hi
I have a Document object created over the xml file, initially having same type of group elements with differen type of information in the predefined order. later if any time i modify it to add new group of same type by default i am able to add it to next sibiling, instead i want to maintain the order.
i am having order number as part of group elemnt attribute order.
e.g
i have initial xml document like below
<product order ="2">
<name/>
<price/>
</product>
<product order ="4">
<name/>
<price/>
</product>
now if the use want to add the anotherelemtn like
<product order ="3">
<name/>
<price/>
</product>
it should go into proper sequence.
How to do this
expected will be
<product order ="2">
<name/>
<price/>
</product>
<product order ="3">
<name/>
<price/>
</product>
<product order ="4">
<name/>
<price/>
</product>Use the element's append() method if you want to add a child element as the last child, otherwise use its insertBefore() method.
-
Load Sales Order from Xml file
Hi,
I want to load a sales order from xml file. How can I do so? Where I'll get the xml schema for Sales Order or other documents (delivery,invoice etc)?
Plz reply with code and xml file.When I'm going to load SO from xml file, it's showing an error:
"The connected value 0 was not found in table Uasge of Nota Fiscal".
What is this table for? Which attribute is related with this table?
How can I find out that? -
Error processing request in sax parser No 'action' attribute found in XML
Hi All,
I am doing a FILE to JDBC Scenario. I just want to send a data from file to Sql Db table. For this I have written a stored procedure to insert the row in a table.
This is the message mapping for FILE to JDBC .
Sender Receiver
*FILESENDER_MT 1..1 FILESENDER_DT * SPRECEIVER_MT 1..1
.NO 1..1 xsd:string * Statement 1..1 string
.Name 1..1 xsd:string *user_PROC 1..1
action 1..1required
*No
isInput 1..1 string
type 1..1 string
*Name
isInput 1..1 string
type 1..1 string
Mapped Values....
Statement is mapped with <b>FILESENDER_MT</b>
action attribute is mapped with "<b>EXECUTE</b>" Constant
No is mapped with <b>NO</b>
Name is mapped with <b>Name</b>
for both isInput is mapped with <b>TRUE</b>
for both type is mapped with <b>CHAR</b>
Here is the my stored procedure.....
CREATE PROCEDURE [dbo].[user_PROC]
@NO char(10), @Name char(10) AS
insert into FILE2JDBC values('a','ab')
GO
when i run this stored procedure in Sql directly it was executed successfully....
I have checked In SXMB_MONI status is showing green...
xml messages from SXMB_MONI ....
this is the message from payloads of Inbound Message
<PRE> <?xml version="1.0" encoding="UTF-8" ?>
- <ns0:FILESENDER_MT xmlns:ns0="http://www.prospectadelhi.com/DELHI_FILE2JDBC">
<NO>111</NO>
<NAME>murthy</NAME>
</ns0:FILESENDER_MT></PRE>
this is the message from payloads of Request Message Mapping
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:SPRECEIVER_MT xmlns:ns0="http://www.prospectadelhi.com/DELHI_FILE2JDBC">
- <Statement>
- <user_PROC>
<action>EXECUTE</action>
- <NO>
<isInput>TRUE</isInput>
<type>CHAR</type>
</NO>
- <Name>
<isInput>TRUE</isInput>
<type>CHAR</type>
</Name>
</user_PROC>
</Statement>
</ns0:SPRECEIVER_MT>
this is the error showing in runtime workbench>component monitoring->communication channel monitoring-->Receiver Communication Channel....
<b>Error while parsing or executing XML-SQL document: Error processing request in sax parser: No 'action' attribute found in XML document (attribute "action" missing or wrong XML structure)</b>
Can any body tell me whether the problem is in Mapping or in Data Type Structure..
Please resolve this issue....
Thanks in Advance,
Murthy.<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:SPRECEIVER_MT xmlns:ns0="http://www.prospectadelhi.com/DELHI_FILE2JDBC">
- <Statement>
<b>- <user_PROC>
<action>EXECUTE</action></b>
- <NO>
<isInput>TRUE</isInput>
<type>CHAR</type>
</NO>
- <Name>
<isInput>TRUE</isInput>
<type>CHAR</type>
</Name>
</user_PROC>
</Statement>
</ns0:SPRECEIVER_MT>
The Action should be a Attribute of Element user_Proc as,
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:SPRECEIVER_MT xmlns:ns0="http://www.prospectadelhi.com/DELHI_FILE2JDBC">
- <Statement>
<b>- <user_PROC action="Execute"></b>- <NO>
<isInput>TRUE</isInput>
<type>CHAR</type>
</NO>
- <Name>
<isInput>TRUE</isInput>
<type>CHAR</type>
</Name>
</user_PROC>
</Statement>
</ns0:SPRECEIVER_MT>
Likewise isInput and Type should be Attributes and not Elements .
Regards
Bhavesh -
ABAP to XML with several internal tables
hi,
i have to make a XML file with this structure :
<Order>
<OrderHeader>
<i>...[fields of header]...</i>
</OrderHeader>
<OrderItem>
<i>...[fields of item 10]...</i>
</OrderItem>
<OrderItem>
<i>...[fields of item n]...</i>
</OrderItem>
</Order>
and that for several orders...
I don't know anything about XML, XLST and since 1 day just start to read doc, tutorial.. and i can't say i'm understanding everythings..
so, in a first step, i have tried to export several Order headers :
I have done a XSLT (thanks to another topic/replies in the forum) and call it with CALL TRANSFORMATION and it works good...
now,and here i need a little help, i would like to know :
1-is it possible to work with 2 internal tables and in this case, how to make XLST looping all item for each header?
2-or should i use only one internal table with deep structure?
Regards,
Christophe
The XSLT
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sapxsl="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<Order>
<xsl:for-each select="//item">
<OrderHeader>
<OrderNo>
<xsl:value-of select="AUFNR"/>
</NoOT>
</OrderHeader>
</xsl:for-each>
</Order>
</xsl:template>
</xsl:transform>Hi,
Here is the sample code.
* Databases
TABLES:
makt, "Mat description
marc, "Material / plant
t001w, "plant name
bhdgd. "Batch heading
* Internal tables
DATA:
BEGIN OF gt_marc OCCURS 0,
werks LIKE marc-werks,
matnr LIKE marc-matnr,
END OF gt_marc,
* Table to be downloaded as xml. Each line stores start and end tags
* and the value
BEGIN OF gt_xml OCCURS 0,
line(120),
END OF gt_xml,
g_maktx(120).
* User-input
SELECT-OPTIONS:
s_werks FOR marc-werks,
s_matnr FOR marc-matnr.
START-OF-SELECTION.
* Extract all required data
PERFORM main_processing.
END-OF-SELECTION.
SORT gt_marc BY werks matnr.
LOOP AT gt_marc.
AT FIRST. "First tag must be root
CLEAR gt_xml.
gt_xml-line = '<LOCATIONS>'.
APPEND gt_xml.
CLEAR gt_xml.
ENDAT.
AT NEW werks. "At new plant
PERFORM read_plant.
FORMAT COLOR 4 ON.
SKIP 1.
WRITE :/ gt_marc-werks, t001w-name1.
FORMAT COLOR 4 OFF.
CLEAR gt_xml.
gt_xml-line = ' <PLANT>'.
APPEND gt_xml.
CLEAR gt_xml.
CONCATENATE ' <NUMBER>' gt_marc-werks '</NUMBER>'
INTO gt_xml-line.
APPEND gt_xml.
CLEAR gt_xml.
CONCATENATE ' <NAME>' t001w-name1 '</NAME>' INTO gt_xml-line.
APPEND gt_xml.
CLEAR gt_xml.
gt_xml-line = ' </PLANT>'.
APPEND gt_xml.
CLEAR gt_xml.
ENDAT.
PERFORM read_description.
CLEAR gt_xml.
gt_xml-line = ' <MATERIAL>'.
APPEND gt_xml.
CLEAR gt_xml.
CONCATENATE ' <NAME>' g_maktx '</NAME>'
INTO gt_xml-line.
APPEND gt_xml.
CLEAR gt_xml.
CONCATENATE ' <NUMBER>' gt_marc-matnr '</NUMBER>'
INTO gt_xml-line.
APPEND gt_xml.
CLEAR gt_xml.
gt_xml-line = ' </MATERIAL>'.
APPEND gt_xml.
CLEAR gt_xml.
* display data
FORMAT COLOR 2 ON.
WRITE :/ gt_marc-matnr, makt-maktx.
FORMAT COLOR 2 OFF.
ENDLOOP.
* The last tag must be the root closing tag --*
gt_xml-line = '</LOCATIONS>'.
APPEND gt_xml.
CLEAR gt_xml.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = 'C:PLANT1.XML'
filetype = 'ASC'
TABLES
data_tab = gt_xml.
TOP-OF-PAGE.
MOVE sy-title TO bhdgd-line1.
MOVE sy-repid TO bhdgd-repid.
MOVE sy-uname TO bhdgd-uname.
MOVE sy-datum TO bhdgd-datum.
MOVE '0' TO bhdgd-inifl.
MOVE '132' TO bhdgd-lines.
FORMAT INTENSIFIED ON COLOR COL_HEADING.
PERFORM batch-heading(rsbtchh0). "report header
* Form READ_PLANT
FORM read_plant.
* Get plant name
CLEAR t001w.
SELECT SINGLE name1
INTO t001w-name1
FROM t001w
WHERE werks EQ gt_marc-werks.
ENDFORM. " READ_PLANT
* Form MAIN_PROCESSING
FORM main_processing.
* Material and plant basic data
SELECT werks matnr
INTO TABLE gt_marc
FROM marc
WHERE werks IN s_werks
AND matnr IN s_matnr.
ENDFORM. " MAIN_PROCESSING
* Form READ_DESCRIPTION
FORM read_description.
* Material name
CLEAR g_maktx.
SELECT SINGLE maktx
INTO g_maktx
FROM makt
WHERE matnr EQ gt_marc-matnr
AND spras EQ 'E'.
* Replace special character
DO.
REPLACE '&' WITH '*ù%;' INTO g_maktx.
IF NOT sy-subrc IS INITIAL. EXIT.ENDIF.
ENDDO.
DO.
REPLACE '*ù%;' WITH '&' INTO g_maktx.
IF NOT sy-subrc IS INITIAL. EXIT.ENDIF.
ENDDO.
DO.
REPLACE '/' WITH '/' INTO g_maktx.
IF NOT sy-subrc IS INITIAL. EXIT.ENDIF.
ENDDO.
ENDFORM. " READ_DESCRIPTION
Hope this helps.If so,kindly reward points.
Maybe you are looking for
-
Is it possible to nest object groups in froms?
Title says it all, but to explain further - I'd like to create some object groups and the objects I'd like to include within these groups are themselves objects groups. Is that possible?
-
Where can I get a custom extension developed?
Things are a bit quiet in the extensions forum, so I thought I'd try posting this here too: I will soon be needing a custom extension built for a software program. Where to I post a job such as this? Is there a forum that specifically hooks up develo
-
Trouble with Windows Service Pack 1 ?
I am using Adobe CreatePDF, and because I am using it with a musical notation software program , Finale, I have to use the Adobe Desktop Printer, to convert the file s. This has worked very well for a couple of months but, the other day I attempted
-
Hi Experts, This could be a basis issue. When I open TCode VKOA in production, the fields are editable, even through the client is set as 'not modifiable'. However, this problem is not there in quality. Any idea what can be the reason for this? Regar
-
Copying files ipad3 gives 'not enough memory'
Hey folks, Very annoying and hard to find an answer to appearently. I am copying files to apps on my new Ipad 3 and I think I've run into some kind of limit. Itunes copies a few files and then throws an error message "File bla bla bla could not be co