Packet queue strategy & data structure
Hi all,
does anyone know an efficient data structure to implement a global packet queue in which packets from different connection are queued (by a thread) and removed by another thread ?
The basic idea is to have the following 2 threads (in pseudo code):
q is the global queue
// write thread
foreach (Connection c : connections) {
Packet p = q.nextPacketToSendToThisConnection
send as much bytes of p as the write() is a non-blocking operation
if (p.bytesToSend == 0) {
q.markPacketAsSendedForConnection(p, c)
// read thread (c is a Connection)
Packet p = c.readPacket()
q.queue(p)Thanks in advance
A simple queue using a linked list will do. Here's an example from some of my network code, the message is just a string, it could be something more complex. Attempts to avoid the synchronization are prone to error and may actually slow your code down.:
LinkedList sendQ = new LinkedList(); // our transmission queue
// the transmit queue
// the transmit thread calls popMessage to get a string to send
synchronized String popMessage()
String msg = null; // returns null if closed
while (state > 0 && sendQ.size() == 0) // wait until data or closed
try{this.wait();} // wait relinguishes lock and lets other threads run
catch(InterruptedException e){} // ignore interrupts
if(state > 0)msg = (String)sendQ.remove(0); // we're open get oldest message form sendQ list
return msg;
// the client calls postMessage to put a string on the transmit queue
synchronized void postMessage(String msg)
sendQ.add(msg); // append to transmit queue
this.notify(); // tell popMessage to take a look
}
Similar Messages
-
Data structure for simulation of message queue
Hello,
I have undertaken a project of simulating the point to point and publish/subscribe protocols of message queueing. This whole project would be done just in Java. There won't be any system level programming. Which data structure in Java would be the most efficient one for the message queue?Hello,
I have undertaken a project of simulating the point to point and publish/subscribe protocols of message queueing. This whole project would be done just in Java. There won't be any system level programming. Which data structure in Java would be the most efficient one for the message queue? -
Website on data structures such as stacks and queues.
Hi,
I'm currently try to read up on data structures such as stacks, queues but don't quite understand how to implement that. Is there any useful links with example that I can read up from?
ThanksDepends what you mean by "implement". If you want to use standard Java classes that are already written, and you want to know which to choose, then
http://java.sun.com/docs/books/tutorial/collections/
If you want to write your own, for some obscure reason, then read a book on data structures. Or try to write your own implementation of the Java collection classes. -
Hi,
I'm hesitant about what data structure to use (best efficient one) in the following scenario
At a given moment I have an ordered set of data such as:
(1,3,6,9,10)
and a current value (by instance, 11)
Then I need to access the LAST one (10) and
If my value is greater I will add it to the list. In this example I will add 11 so the list will be (1,3,6,9,10,11)
On the other hand, as a second step, I will iterate on the list as follows: I will get the first element, do something, then remove it, and go to next one until the list is empty. Therefore, basically I will access always the first element on the list.
I don't really care about the elements in the middle.
Which data structure do you suggest me to use?
I was thinking on Queue (easy to access the head, and extract one by one in order), but I don't know how to get the tail element (10 in this case), as it is the one that tells me if I have to add another element...
Thank you.>
At a given moment I have an ordered set of data such as:
(1,3,6,9,10)
and a current value (by instance, 11)
Then I need to access the LAST one (10) and
If my value is greater I will add it to the list. In this example I will add 11 so the list will be (1,3,6,9,10,11)Any data structure will do, I would suggest a LinkedList.
On the other hand, as a second step, I will iterate on the list as follows: I will get the first element, do something, then remove it, and go to next one until the list is empty. Therefore, basically I will access always the first element on the list.Use an iterator and the corresponding remove methods.
Mel -
Relationship between Dynamic Memory Heap and Heap Data Structure
This question is not strictly related to Java, but rather to programming in general, and I tend to get better answers from this community than any where else.
Somehow, my school and industry experience have somehow not given me the opportunity to explore and understand heaps (the data structure), so I'm investigating them now, and in particular, I've been looking at applications. I know they can be used for priority queues, heap sorts, and shortest path searches. However, I would have thought that, obviously, there must be some sort of relationship between the heap data structure, and the dynamic memory heap. Otherwise, I can think of no good reason why the dynamic memory heap would be named "heap". Surprisingly, after searching the web for 90 minutes or so, I've seen vague references, but nothing conclusive (trouble seems to be that it's hard to get Google to understand that I'm using the word "heap" in two different contexts, and similarly, it would not likely understand that web authors would use the word in two different contexts).
The Java Virtual Machine Spec is silent on the subject, as "The Java virtual machine assumes no particular type of automatic storage management system, and the storage management technique may be chosen according to the implementor's system requirements."
I've seen things like:
[of dynamic memory] "All the blocks of a particular size are kept in a sorted linked list or tree (I extrapolate that sorted tree could imply heap)"
[of dynamic memory] "The free and reserved areas of memory are maintained in a data structure similar to binary trees called a heap"
[of dynamic memory] "This is not related to the heap data structure"
[of dynamic memory] "Not to be confused with the data structure known as a "heap"
[of data structure] "Not to be confused with the dynamic memory pool, often known as TheHeap"
At this point, I've come to surmise that some (but not all) memory management algorithms use heaps to track which (pages? blocks? bytes?) of memory are used, and which are not. However, the point of a heap is to store data so that the max (or min) key is at the root of the heap. But we might want to allocate memory of different sizes at different times, so it wouldn't make sense to key on the amount of available memory in a particular region of the free store.
I must assume then that there would be a different heap maintained for each size of memory block that can be allocated, and the key must have something to do with the attractiveness of the particular memory block in the heap (perhaps the lowest address, resulting, hopefully, in growing the free store space less often, leaving more space for the stack to grow, or perhaps keyed based on the fragmentation, to hopefully result in less fragmentation, and therefore more efficient use of the memory space, or perhaps based on page boundaries, keeping as much data in the same page as possible, etc).
So at this point, I have a few questions I've been unable to resolve completely:
1. Am I correct that the heap was so named because (perhaps at one point in time), a heap is/was commonly used to track the available memory in the free store?
2. If so, would it be correct that there would be a heap per standard block size?
3. Also, at what level of granularity would a heap typically be used (memory page, memory blocks, individual words (4-bytes))?
4. What would be the most likely property one would use as a key. That is, what makes the root item on the heap ideal?
5. Would a industrial strength system like the jvm use a (perhaps modified or tuned) heap for this sort of task, or would this typically be too naive for an real world solution today?
Any insight would be awesome!
Thanks,
A.jschell wrote:
I think you are not only mixing terms but domains.
For starters the OS allocs memory. Applications, regardless of language, request memory from the OS and use it in various ways.
There are many variations of the term "heap" like the following.
[http://en.wikipedia.org/wiki/Heap_(data_structure)]
[http://en.wikipedia.org/wiki/Dynamic_memory_allocation]
A java VM will request memory from the OS (from a 'heap') and use it in its application 'heap' (C/C++) and then create the Java 'heap'. There can be variations of that along the way that can and likely will include variations of how each heap is used, potentially code that creates its own heap, and potentially other allocators which use something which is not a heap.This last part, I find a bit confusing. By "use something which is not a heap", do you mean the heap data structure, or the dynamic memory pool meaning of heap? If the former, then you would be implying that it would be common for a heap data structure to be used to manage the heap dynamic memory pool. If the latter, what would this "something which is not a heap" be? The best definition of "heap" I've found simply states that it is a pool of memory that can be dynamically allocated. If there is some other way of allocating dynamic memory, then it would suggest that the previous definition of "heap" is incomplete.
>
So to terms.
1. Am I correct that the heap was so named because (perhaps at one point in time), a heap is/was commonly used to track the available memory in the free store?Which 'heap'? The VM one? It is probably named that because the implementors of the Sun VM were familar with how C++ and Smalltalk allocated memory.Okay, but that begs the question, was the heap in C++ and/or Smalltalk so named for the above queried reason?
>
2. If so, would it be correct that there would be a heap per standard block size?Not sure what you are referring to but probably a detail of the implementation. And since there are different levels the question doesn't mean much.
However OS allocations are always by block if that helps. After that it requires making the question much, much more specific.
3. Also, at what level of granularity would a heap typically be used (memory page, memory blocks, individual words (4-bytes))?Again not specific enough. A typical standard implementation of heap could not be at the word level. And it is unlikely, but not impossible, that variations would support word size allocations.
The VM heap might use word boundaries (but not size), where the application heap certainly does (word boundary.)My understanding of it is that the application would request blocks from the OS, and then something like malloc would manage the memory within the allocated blocks. malloc (or whatever equivalent Java uses) would have to keep track of the memory it has allocated somehow, and I would think it would have to do this at the word level, since it's most commonly going to allocate memory at the word level to be references to other objects, etc.
So I guess my question here would really be, if the dynamic memory heap is so named because there has been a memory management strategy that relied upon a heap data structure (which I've found no proof, but have found some suggestive literature), then would that probably have applied at the OS Page Fault level, tracking allocated blocks, or would that have applied at the malloc level, allocating individual words as necessary?
>
4. What would be the most likely property one would use as a key. That is, what makes the root item on the heap ideal?"Key" is not a term that will apply in this discussion.
You appear to be referring to strategies for effective allocation of memory such as allocations from different regions by size comparison.
It is possible that all levels might use such an allocator. General purpose applications do not sort allocations though (as per your one reference that mentions 'key'.) Sorry, I got the term "key" from an article I read regarding heaps, that indicates that a "key" is used to sort the elements, which I guess would be a more generalized way to make a heap than assuming a natural ordering on the elements in the heap. I'm not sure if the terminology is standard.
>
5. Would a industrial strength system like the jvm use a (perhaps modified or tuned) heap for this sort of task, or would this typically be too naive for an real world solution today?Again too indefinite. The Sun VM uses a rather complicated allocator, the model for which originated after years of proceeding research certainly in Smalltalk and in Lisp as well, both commercially and academically.
I am sure the default is rules driven either explicitly or implicitly as well. So it is self tuning.
There are command line options that allow you to change how it works as well.I guess perhaps I could attempt to clarify my initial question a bit.
There is a 1:1 correspondence between the runtime stack, and a stack data structure. That is, when you call a function, it pushes a stack frame onto the runtime stack. When you return from a function, it pops a stack frame from the runtime stack. This is almost certainly the reasons the runtime stack is named as it is.
The question is, is there or has there ever been a 1:1 correspondence between some aspect of the dynamic memory heap or how it is managed, and a heap data structure? If so, it would explain the name, but I'm a bit puzzled as to how a heap data structure would be of assistance in creating or managing the dynamic memory heap. If not, on the other hand, then does anybody know where the name "heap" came from, as it applies to the dynamic memory pool?
A. -
ODI 11g : JMS Queue XML Data Server creation
Hi Everybody,
I am facing a problem while i am trying to create a JMS Queue XML data server in ODI 11g. I have
the following details of the queue.
QueueManager=xxx;
TransportType=1;
HostName=ab.cde.fe.com;Port=77777;
Channel=CLIENT.TO.xxx1
destination name : SU.BH.RAJY.OTI.UPDATE_ITEM_RESPONSE.01
user : xyz
password : 123
I have sussefully created an jms datasouce in weblogic name 'eis/jms/abc' and also I have successfully
retrived the xml message from queue in BPEL
(using a jms adapter where
JMS Provider : Third Party,
Jms Provider Jndi Name -eis/jms/abc,
Operation name : consume_message,
destinamtion name is queue:///SU.BH.RAJY.OTI.UPDATE_ITEM_RESPONSE.01?targetClient=1).
But the new reqirement is to retive the xml data in ODI using "JMS Queue XML data server".I have tried
several ways(reading from internet) but failed to configure physical dataserver and reverse the xml message.
Also failed to understand properly the oracle post (http://docs.oracle.com/cd/E21764_01/integrate.1111/e12644/jms_xml.htm#CHDFCFBI).
Speically this portion "JNDI URL: <JMS_RESOURCE>?d=<DTD_FILE>&s=<SCHEMA>&JMS_DESTINATION=<JMS_DESTINATION_NAME>.".
What will be the "JMS_RESOURCE" in my case.
How can I configure JMS Queue XML?
Please help!
Note : I don't have the XML message structure of the Queue(also DTD file). So , I have to reverse it.
Thanks & Regards,
Subhra
Message was edited by: SubhrajyotiKunduHi Everybody,
I am facing a problem while i am trying to create a JMS Queue XML data server in ODI 11g. I have
the following details of the queue.
QueueManager=xxx;
TransportType=1;
HostName=ab.cde.fe.com;Port=77777;
Channel=CLIENT.TO.xxx1
destination name : SU.BH.RAJY.OTI.UPDATE_ITEM_RESPONSE.01
user : xyz
password : 123
I have sussefully created an jms datasouce in weblogic name 'eis/jms/abc' and also I have successfully
retrived the xml message from queue in BPEL
(using a jms adapter where
JMS Provider : Third Party,
Jms Provider Jndi Name -eis/jms/abc,
Operation name : consume_message,
destinamtion name is queue:///SU.BH.RAJY.OTI.UPDATE_ITEM_RESPONSE.01?targetClient=1).
But the new reqirement is to retive the xml data in ODI using "JMS Queue XML data server".I have tried
several ways(reading from internet) but failed to configure physical dataserver and reverse the xml message.
Also failed to understand properly the oracle post (http://docs.oracle.com/cd/E21764_01/integrate.1111/e12644/jms_xml.htm#CHDFCFBI).
Speically this portion "JNDI URL: <JMS_RESOURCE>?d=<DTD_FILE>&s=<SCHEMA>&JMS_DESTINATION=<JMS_DESTINATION_NAME>.".
What will be the "JMS_RESOURCE" in my case.
How can I configure JMS Queue XML?
Please help!
Note : I don't have the XML message structure of the Queue(also DTD file). So , I have to reverse it.
Thanks & Regards,
Subhra
Message was edited by: SubhrajyotiKundu -
I am looking for the best and simplest way to create and manage data structures in Labview.
Most often I use clusters as data structures, however the thing I don't like about this approach is that when I pass the cluster to a subroutine, the subroutine needs a local copy of the cluster.
If I change the cluster later (say I add a new data member), then I need to go through all the subroutines with local copies of the cluster and make the edit of the new member (delete/save/relink to sub-vi, etc).
On a few occasions in the past, I've tried NI GOOP, but I find the extra overhead associated with this approach cumbersome, I don't want to have to write 'get' and 'set' methods for every integer and string, I like being able to access the cluster/object data via the "unbundle by name" feature.
Is there a simple or clever way of having a single global reference to a data object (say a cluster) that is shared by a group of subroutines and which can then be used as a template as an input or output parameter? I might guess the answer is no because Labview is interpreted and so the data object has to be passed as a handle, which I guess is how GOOP works, and I have the choice of putting in the extra energy up front (using GOOP) or later (using clusters if I have to edit the data structure). Would it be advisable to just use a data cluster as a global variable?
I'm curious how other programmers handle this. Is GOOP pretty widely used? Is it the best approach for creating maintainable LV software ?
AlexAlex,
Encapsulation of data is critical to maintaining a large program. You need global, but restricted, access to your data structures. You need a method that guarantees serial, atomic access so that your exposure to race conditions is minimimized. Since LabVIEW is inherently multi-threaded, it is very easy to shoot yourself in the foot. I can feel your pain when you mention writing all those get and set VIs. However, I can tell you that it is far less painful than trying to debug a race condition. Making a LabVIEW object also forces you to think through your program structure ahead of time - not something we LabVIEW programmers are accustomed to doing, but very necessary for large program success. I have use three methods of data encapsulation.
NI GOOP - You can get NI GOOP from the tutorial Graphical Object Oriented Programming (GOOP). It uses a code interface node to store the strict typedef data cluster. The wizard eases maintenance. Unfortunately, the code interface node forces you through the UI thread any time you access data, which dramatically slows performance (about an order of magnitude worse than the next couple of methods).
Functional Globals - These are also called LV2 style globals or shift register globals. The zip file attached includes an NI-Week presentation on the basics of how to use this approach with an amusing example. The commercial Endevo GOOP toolkit now uses this method instead of the code interface node method.
Single-Element Queues - The data is stored in a single element queue. You create the database by creating the queue and stuffing it with your data. A get function is implemented by popping the data from the queue, doing an unbundle by name, then pushing the data back into the queue. A set is done by popping the data from the queue, doing a bundle by name, then pushing the data back into the queue. You destroy the data by destroying the queue with a force destroy. By always pulling the element from the queue before doing any operation, you force any other caller to wait for the queue to have an element before executing. This serializes access to your database. I have just started using this approach and do not have a good example or lots of experience with it, but can post more info if you need it. Let me know.
This account is no longer active. Contact ShadesOfGray for current posts and information. -
Implement a program by using data structure
i've learn link-list,b-tree,red black tree,hash table. now it's time for me to implement a program using any one of these. i've no idea about how to start, and what kind of program should i write? what kind of program use data structure? i want some simple example program to make me understand. can anyone help me?
thank 4 u r time,
makiowhat sort of program do use data structure? let's say
i want to use binary search on data , how can i?As nasch said: pretty much any program uses data structures.
Okay, let's say you want to try binary search. You could do that on an array, on a singly linked list, on a doubly linked list, probably on others that I can't think of right now.
If you just want practice using the data structures you've learned, then why not write a binary search over several different ones? That will give you a feel for how they differ in usage and performance.
Or, you can just pick any kind of program that interests you. Unless it's trivially small and simple, there will probably be a use for one or more of the data strux you've learned.
A chat program needs data structures to hold curently connected users, ongoing conversations, maybe a queue for messages waiting to be sent.
A card game needs to be able to search to see if a given card is in a given hand. Needs to hold all the cards in a deck that has to be shuffled. Dealing is like popping off a stack.
A database of students and their courses might want to keep something in an ordered tree--by last name for instance.
What applications interest you? -
Friends,
I am giving a session on "Data structures and SQL Server" for one of the SQL Server communities in India.
My idea is to explain high level concepts of data structures (Stacks, Queues, Linked lists, Trees, Graphs etc.)
here are my questions.
Like to know how data structure concepts are implemented SQL Server components (in a high level).
Here are some hints in my mind:
1. Queues - SQL Server - DMVs for Processor Queue length, Disk Queue length etc.
2. Linked Lists - SQL Server - Previous and Next page pointers in Page headers (and DBCC IND)
3. Trees - SQL Server - Btrees in Indexes (DBCC IND and DBCC PAGE of Index pages)
3. Linear Search - SQL Server - Table Scan
4. Binary Search - SQL Server - Index Seek
What i need is:
1. Sorting algorithm used in SQL Server?
2. Stack concept used in SQL Server? I think No
3. what else data structure concepts are implemented in SQL Server (that can be demonstrated)
Note: level: 300 - Intermediate to Advanced.
Thanks in advance
Ramkumar
[email protected]
Ramkumar Gopal Living For SQL Server Blog: http://www.sqlservercentral.com/blogs/livingforsqlserver/ Facebook: https://www.facebook.com/#!/groups/livingforsqlserver/ Twitter: https://twitter.com/LivingForSQLHello,
Take a look at some structures created for In-Memory OLTP (hash indexes, etc.)
http://download.microsoft.com/download/5/F/8/5F8D223F-E08B-41CC-8CE5-95B79908A872/SQL_Server_2014_In-Memory_OLTP_TDM_White_Paper.pdf
BUF Structures.
http://blogs.msdn.com/b/karthick_pk/archive/2013/03/16/sql-server-memory.aspx
Hope this helps.
Regards,
Alberto Morillo
SQLCoffee.com -
I have been searching online for this answer for quite a long time so i hope you guys can help.
I would like to know the name of the data structure used when a program stores data to a file by writing each data entry in one line. So for example if I want to store X number of names in a file. Each name take up one line of a file, and each name is a string. Would that be called sequential access?
Thanks!I think the point here is that you are not really referring to a data structure. A data structure is, essentially, a set of operations over data. Typically, data structures are classes, and only exist in memory. Examples of data structures are Collection, Set, List, Map, SortedSet, SortedMap, Queue, Stack. These data structures are defined by their operations. For example, a Stack allows you to push data, or pop data.
You appear to be talking about a file format. Text data, stored one item per line. I would not call that a data structure. I might see that in an interface description document, relating to how data will be transfered or stored externally.
¦ {Þ -
Create jms queue xml data server
Hi,
What's the difference between jms queue and jms queue xml data servers and how to create jms queue xml data server.
Thanks.Hello,
JMS messages can principally be processed by Oracle Data Integrator in two formats:
- JMS Messages: containers for rows of data, handled through JMS Queue/JMS Topic Technologies. With JMS Queue/JMS Topic technologies, each JMS destination is defined similarly to a flat file datastore. Each message in the destination is a record in the datastore.
- XML Messages: containers for XML files, handled through JMS XML Queue/JMS XML Topic Technologies. With JMS XML Queue/JMS XML Topic technologies, each messages payload contains a complete XML data structure. This structure is mapped into a relational schema (XML Schema) which appears as a model. This use the Oracle DI Driver for XML (see the driver documentation in Oracle DI documentation).
Find below a step by step creation process for such a destination:
1. Data Server
To create a JMS XML Queue data server, you declare a simple JNDI connection. The only JMS XML specific information is added to the URL. This information defines the XML file format.
The JNDI URL should be : <JMS_RESOURCE>?d=<DTD_FILE>&f=<XML_FILE>&s=<SCHEMA>&JMS_DESTINATION=<JMS_DESTINATION_NAME>
- JMS_RESOURCE: JNDI resource corresponding to your JMS queue that will contain the XML payload. You would specify this URL if you were managing normal JMS messages.
- DTD_FILE: path to a DTD file that describes the XML structure. Mandatory if the parameter XML_FILE is omitted.
- XML_FILE: path to the XML file with a structure similar to the expected XML messages. Mandatory if the DTD_FILE parameter is omitted.
- SCHEMA: schema name that will contain the XML structure. This value must match the one set for the physical schema attached to this data server. This parameter is mandatory.
- JMS_DESTINATION_NAME: name of the JMS queue or topic. This parameter is mandatory.
2. Schema
Creation is straightforward: In the Schema (Schema) and Schema (Work Schema), enter the name of the <SCHEMA> defined in the data server JNDI URL.
3. Model
Use standard reverse-engineering. As the Oracle DI Driver for XML is used the XML structure will be reversed as a relational structure.
Regards,
- FX -
When to use specific data structures
Hi
I'm currently learning Java and have found a wealth of information on data structures (link lists,queues et. al.) but I'm finding not much material on when best to apply specific data structures and the advantages and disadvantages. Could anyone point me to any resources?
Second question as a Java developer do you actually use things like linked lists etc regularly?
Thanks in advanceI suppose that a wealth of information exists because data structures are an integral part of programming. In simpler terms, all that information exists because the answer to question two is yes, absolutley.
The answer to question one is a bit trickier. It's kind of like asking when is best to use a flathead vrs. a phillips screwdriver. The answer seems obvious within a given context, but obscure outside of one.
IMHO: The 'when' becomes clear with experience. Focus on the 'how' and you'll be ready when you are faced with a problem that calls for a particular type of solution.
jch -
Which is a efficient Data Structure to store data in a file
I want tostire a data in file in sorted order. I am thinking about Bainary Search tree & heap sort Which is efficient technique. Please reply..
which is the best data structure to be used in Thread
pool to store the thread instances? and why ?
I have seen lots of people using Queue....Why do you ask? You do know that there are thread pool classes in Java 5?
Kaj -
H!!
I am looking for a good on line tutorial about
Java Data structure. please help me.
peterHi again!
This is my first time that I want to learn
about : stack, list, linked list, queue, tree..
. whit Java.Stack, list, linked list, queue and trees are data structures which are the same independent of the programming language. They are more of a concept.
The best way to find more information is to google on the structure you want more information on. Here's an explanation on how a linked list works:
http://encyclopedia.lockergnome.com/s/b/Linked_list
/Kaj -
Simple Transformation to deserialize an XML file into ABAP data structures?
I'm attempting to write my first simple transformation to deserialize
an XML file into ABAP data structures and I have a few questions.
My simple transformation contains code like the following
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
xmlns:pp="http://www.sap.com/abapxml/types/defined" >
<tt:type name="REPORT" line-type="?">
<tt:node name="COMPANY_ID" type="C" length="10" />
<tt:node name="JOB_ID" type="C" length="20" />
<tt:node name="TYPE_CSV" type="C" length="1" />
<tt:node name="TYPE_XLS" type="C" length="1" />
<tt:node name="TYPE_PDF" type="C" length="1" />
<tt:node name="IS_NEW" type="C" length="1" />
</tt:type>
<tt:root name="ROOT2" type="pp:REPORT" />
<QueryResponse>
<tt:loop ref="ROOT2" name="line">
<QueryResponseRow>
<CompanyID>
<tt:value ref="$line.COMPANY_ID" />
</CompanyID>
<JobID>
<tt:value ref="$line.JOB_ID" />
</JobID>
<ExportTypes>
<tt:loop>
<ExportType>
I don't know what to do here (see item 3, below)
</ExportType>
</tt:loop>
</ExportTypes>
<IsNew>
<tt:value ref="$line.IS_NEW"
map="val(' ') = xml('false'), val('X') = xml('true')" />
</IsNew>
</QueryResponseRow>
</tt:loop>
</QueryResponse>
</tt:loop>
1. In a DTD, an element can be designated as occurring zero or one
time, zero or more times, or one or more times. How do I write the
simple transformation to accommodate these possibilities?
2. In trying to accommodate the "zero or more times" case, I am trying
to use the <tt:loop> instruction. It occurs several layers deep in the
XML hierarchy, but at the top level of the ABAP table. The internal
table has a structure defined in the ABAP program, not in the data
dictionary. In the simple transformation, I used <tt:type> and
<tt:node> to define the structure of the internal table and then
tried to use <tt:loop ref="ROOT2" name="line"> around the subtree that
can occur zero or more times. But every variation I try seems to get
different errors. Can anyone supply a working example of this?
3. Among the fields in the internal table, I've defined three
one-character fields named TYPE_CSV, TYPE_XLS, and TYPE_PDF. In the
XML file, I expect zero to three elements of the form
<ExportType exporttype='csv' />
<ExportType exporttype='xls' />
<ExportType exporttype='pdf' />
I want to set field TYPE_CSV = 'X' if I find an ExportType element
with its exporttype attribute set to 'csv'. I want to set field
TYPE_XLS = 'X' if I find an ExportType element with its exporttype
attribute set to 'xls'. I want to set field TYPE_PDF = 'X' if I find
an ExportType element with its exporttype attribute set to 'pdf'. How
can I do that?
4. For an element that has a value like
<ErrorCode>123</ErrorCode>
in the simple transformation, the sequence
<ErrorCode> <tt:value ref="ROOT1.CODE" /> </ErrorCode>
seems to work just fine.
I have other situations where the XML reads
<IsNew value='true' />
I wanted to write
<IsNew>
<tt:value ref="$line.IS_NEW"
map="val(' ') = xml('false'), val('X') = xml('true')" />
</IsNew>
but I'm afraid that the <tt:value> fails to deal with the fact that in
the XML file the value is being passed as the value of an attribute
(named "value"), rather than the value of the element itself. How do
you handle this?Try this code below:
data l_xml_table2 type table of xml_line with header line.
W_filename - This is a Path.
if w_filename(02) = '
open dataset w_filename for output in binary mode.
if sy-subrc = 0.
l_xml_table2[] = l_xml_table[].
loop at l_xml_table2.
transfer l_xml_table2 to w_filename.
endloop.
endif.
close dataset w_filename.
else.
call method cl_gui_frontend_services=>gui_download
exporting
bin_filesize = l_xml_size
filename = w_filename
filetype = 'BIN'
changing
data_tab = l_xml_table
exceptions
others = 24.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Maybe you are looking for
-
IDCS5/MAC - GREP Style to uppercase a letter after a dash between words
G'day there. I'm trying to create a GREP style to uppercase a letter after a dash between words, more specifically where one word starts with a capital and the one after a dash does not e.g. Lorem-ipsum = Lorem-Ipsum The full story is that there is a
-
somebody can helpme please
-
HR - dynamic selections field name and field value in the program
HI all, I am using dynamic selections for a HR report. I have created a view with 20 fields and added it to HR report category ___00003(All fields suppressed). I need to check these fields in the program. But i am not able to get the field name an
-
Plz help me in creating swing interface
Hi, Iam new to swing.I have one Interface on swing.Now I want to add Jfilechooser object in my interface for selecting file from hard drive.So that I can upload this file through my servlet uploading programme.I want to set remote url also for saving
-
Excel spreadsheet control for 64 bit windows OS
Hi all, I'm looking for a way to use excel (or something equivalent) in a 64 bit labview application. I've been using OWC11 in a 32 bit application to allow users to take advantage of most excel functions and build a table that is used by the applic