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 ...
Similar Messages
-
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.
Walterbut 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 -
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 -
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. -
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? -
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 -
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. -
How to use File Adapter with hierarchial Structure?
Hi,
How to use File Adapter with hierarchial Structure like..
Data:
--Header Details:
Line Item Details:
Data
Bcoz I am getting a Flatfile in a hierarchial way as shown below.
Header Details :1
Line Item a
Line Item b
Header Details :2
Line Item c
Line Item d
KishoreHey Kishore,
In order to create a structure you need to use the file with convertion mode on the sending communication channel of the file adapter.
check the link for the needed configuration paramters.
If the structure is more complexed you can use the Contetnt master(CM) from itemfield which allows to ceate XML file from complex flat files and more.
<a href="http://help.sap.com/saphelp_erp2005/helpdata/en/0d/5ab43b274a960de10000000a114084/frameset.htm">File sender adapter</a>
If you have any question i'll be more than happy to assist.
Nimrod Gisis -
Output XML with a default namespace using XQuery
I'm having a problem with namespaces in an XQuery within ALSB.
We receive XML from a file which doesn't have any namespace and have to transform it into a different structure, giving it a default namespace such as below:
Input XML
<inputRoot>
<inputAccountName>Joe Bloggs</inputAccountName>
<inputAccountNumber>10938393</inputAccountNumber>
</inputRoot>
Desired output XML
<outputRoot xmlns="http://www.example.org/outputSchema">
<outputAccounts>
<outputAccountName>Joe Bloggs</outputAccountName>
<outputAccountNumber>10938393</outputAccountNumber>
</outputAccounts>
</outputRoot>
When I attempt to do this using XQuery mapper tool, I end up with a namespace prefix on the outputRoot. The XQuery and result follows:
XQuery
declare namespace xf = "http://tempuri.org/XQueryProject/scratchTransformations/test/";
declare namespace ns0 = "http://www.example.org/outputSchema";
declare function xf:test($inputRoot1 as element(inputRoot))
as element(ns0:outputRoot) {
<ns0:outputRoot>
<outputAccounts>
<outputAccountName>{ data($inputRoot1/inputAccountName) }</outputAccountName>
<outputAccountNumber>{ data($inputRoot1/inputAccountNumber) }</outputAccountNumber>
</outputAccounts>
</ns0:outputRoot>
declare variable $inputRoot1 as element(inputRoot) external;
xf:test($inputRoot1)
Result
<ns0:outputRoot xmlns:ns0="http://www.example.org/outputSchema">
<outputAccounts>
<outputAccountName>inputAccountName_1</outputAccountName>
<outputAccountNumber>inputAccountNumber_1</outputAccountNumber>
</outputAccounts>
</ns0:outputRoot>
How can I write the XQuery in such a way thay the namespace prefix isn't output? I've tried many different methods with no success. I can't declare a default element namespace because my input element doesn't have a namespace
Thanks in advanceI spoke too soon, it didn't work quite as perfectly as I'd thought :-) It turns out our client can't handle the xml with the namespace prefix but we've worked out the solution to return XML in the format we originally needed.
Example below:
XQuery
declare namespace xf = "http://tempuri.org/XQueryProject/scratchTransformations/test/";
declare default element namespace "http://www.example.org/outputSchema";
declare namespace ns1 = ""
declare function xf:test($inputRoot1 as element(ns1:inputRoot))
as element(outputRoot) {
<outputRoot>
<outputAccounts>
<outputAccountName>{ data($inputRoot1/inputAccountName) }</outputAccountName>
<outputAccountNumber>{ data($inputRoot1/inputAccountNumber) }</outputAccountNumber>
</outputAccounts>
</outputRoot>
declare variable $inputRoot1 as element(inputRoot) external;
xf:test($inputRoot1) -
Content based routing and XML with multiple objects
I have some structure:
<contracts>
<contract>
<department>1</department>
</contract>
<contract>
<department>1</department>
</contract>
<contract>
<department>2</department>
</contract>
</contracts>
I need to route contract to 2 system based on <department> value:
contracts/department = 1 --> System1
contracts/department = 2 --> System2
Will XI split my XML (based on Content Routing rules in ID) into 2 structures (with departmet=1 and department=2 accordingly) ?
Or I have to perform 1ToN mapping? I don't like it bacause it will be diffucult to monitor hundred of messages.Alternatively if you donot like 1:n mapping and BPM.
Create two message mappings in the IR
1.Source :<contracts>
<contract>
<department>1</department>
</contract>
<contract>
<department>1</department>
</contract>
<contract>
<department>2</department>
</contract>
</contracts>
Target:
<contracts>
<contract>
<department>1</department>
</contract>
<contract>
<department>1</department>
</contract>
Basically mapping generates a target structure which has only department 1.
2.Same like step1 but the mapping should generate the XML with department = 2.
Once requires steps are done in the ID , do the content based routing in the reciever determination and give the appropraite message mapping in the interface determination.
That should your problem and also you will like doing it as it does not involve any split level mapping..:) -
EBS-R12 Generate XML (with data) from Embedded Data Definition
Hi
I'm new to running XMLP/BIP in EBS.
I have found the extensive set of data definitions and templates in EBS and they work great out of the box.
I, however, need to make template modifications.
To this end, a correctly structured XML data template - containing all the data fields - is needed for loading into the template-builder in Word.
If for example I take the embedded R12 data definition - XLAJELINESRPT.xml - for Posted Payable Invoices, and load it into the template builder, it provides the structure of the data template and not the structure of the output XML data.
I have tried several ways to run the Data definition through XMLP using the concurrent manager attempting to intercept the generated XML (with data) but it either completes the process and uses the linked output template - producing the PDF - or other output - or if I remove the (output template altogether) it fails with an error.
Maybe I'm missing an obvious step, but there has to be a way of taking the very comprehensive Data Definitions embedded in R12 EBS and using them in custom report templates.
If I've totally missed the point, please give me the steps to follow.
Many thaks in anticipation.
Mike MacMurrayHI Mike,
You cannot load your Data Template into the MS Word Template Builder plugin, as it cannot be run to generate XML this way.
You have two options to get the data from an XML Publisher Report run as a concurrent program in EBS.
1) Using the XML Publisher Administrator responsibility, set an end date for both the Data Defintion and Template Definitions associated with the XLAJELINESRPT report.
2) Leave the concurrent program, Data Defintions and Template Definitions exactly as they are and run the report. Once the report has completed, select the Concurrent Request, click "Diagnostics" then click "View XML". This will open the XML in a new browser window. You can then right click, View Source and then save this document locally.
You can then load this XML into the MS Word Template Builder and start building your template.
I hope this helps.
Regards,
Cj -
Capture data in 1D barcode upon merging XML with XDP?
Hi,
The scenario is:
Forms Server 7.2.2 is being used for merging XML data with an XDP file to render a PDF (displaying a pre-filled form to user).
On the XDP, there is a 1D Barcode and few fields are mapped to this barcode (the barcode is intended to capture form identification information).
Upon merging, the barcode should capture the data of those fields (data is being fetched from a db and fed as XML to Forms server). This is required as the pre-filled form will be printed and then mailed to another location, where the barcode will be read using a decoder to capture form indentification.
Will the 1D barcode captures data from those fields, after merging XML with XDP?
The form is NOT Reader Extended. Is Reader Extending a necessity for enabling 1D barcode to capture data?
Is this also applicable for 2D barcodes?
Thanks a lot for your help! :)Thank you Hodmi,
I had forgotten to define the Record name parameter in the PDF Output Options.
As the XML structure changed, not upating this parameter was preventing the process from working.
Now it is working just fine. Thank you!
Marcos -
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 -
Pass the internal table with different structures to the class module
Hi ,
I have created a class method to fill up the data in XML format. the method can be called from various programs with internal table with different structures. I want to pass it as dynamic How can I do that.
I tried to declare that as type any.
but not working.
regards,
MadhuriHi,
You could work with data reference.
Use GET REFERENCE OF itab INTO data_ref for passing the internal table to your method, and dereference it within the method with ASSIGN statement...
DATA: lr_data TYPE REF TO data.
GET REFERENCE OF itab INTO lr_data.
CALL METHOD meth EXPORTING pr_data = lr_data.
METHOD meth.
FIELD-SYMBOLS <fs> TYPE ANY TABLE
ASSIGN pr_data->* TO <fs>.
ENDMETHOD.
Kr,
Manu.
Maybe you are looking for
-
Soon-to-be Macbook Pro convert asks questions
Hi there! I have had Windows PCs in the past and i want some change. i want to do things more quicker & simplier. I have been researching for the past week or so a comparison on Apple Macs and the latest crop of Windows 7 laptops and i wanted to ask
-
Before I can update my iPad from 7.0.4 to 7.0.6 I am told I must transfer some purchases to iTunes library. How do I identify these purchases, find them and then transfer them to the iTunes library?
-
Firefox keeps on crashing, - 4 times in an hour! Please help
Recently upgraded to 4.0b6 and Firefox keeps on crashing. It starts out by getting progressively slower and slower, then freezing for a few seconds, then just crashes and all tabs close. On restart everything is mostly saved and I can continue workin
-
Native Recompilation of database
Hi, I am trying to recompile my complete database in Native mode using dbmsupgnv.sql and utlrp.sql. Since my database is small sized, I am not getting any performance implications in the NCOMP recompilation process. Since the invalidation of program
-
Hi, my current plans and products include Creative Cloud Photography plan (one-year) and Creative Cloud single-app membership for Photoshop (one-year), I only use photoshop occasionally and for very basic things, are these two plans required for basi