Sorting XML Data
Hi, I didn't want to bury this in the previous thread. The
Doc examples seem to show this process by creating an array in the
code. How do I?:
• Convert the data from an XML file pulled using
HTTPService into an arrayCollection? (I think that's what I'm
supposed to do)
• Sort the data based on chosen field like
• Display the sorted data (or a way to call it)
That's it. ! I think there should be more of this covered in
the docs and definitely an article/quick start ;) Cheers
Macradobe
if you don't want to convert the xml dom to your own datastructures, you could use xslt and the sort element:
http://www.w3schools.com/xsl/xsl_sort.asp
Similar Messages
-
How to use XmlModify to sort the XML Data?
Hello,
I saw some examples explain how to use XmlModify in BDB XML package. I want to sort the XML data by several elements but my Java program could not work correctly.
<CustomerData>
<Transaction>
<DLSFIELDS>
<ADR_PST_CD>12345</ADR_PST_CD>
<CLT_IRD_NBR>002</CLT_IRD_NBR>
</DLSFIELDS>
</Transaction>
<Transaction>
<DLSFIELDS>
<ADR_PST_CD>12345</ADR_PST_CD>
<CLT_IRD_NBR>102</CLT_IRD_NBR>
</DLSFIELDS>
</Transaction>
// many nodes like transaction ...
</CustomerData>
My XQuery script was executed successfully in the shell. The script looks as follows:
"for $i in collection('sample.dbxml')/CustomerData/Transaction order by xs:decimal($i//ADR_PST_CD), xs:decimal($i//CLT_IRD_NBR) return $i".
The Java code :
// create XmlManager
XmlManager manager = // ...;
// open XmlContainer
XmlContainer container = // ...;
XmlQueryContext context = manager.createQueryContext(XmlQueryContext.LiveValues, XmlQueryContext.Eager);
XmlQueryExpression expression = manager.prepare("for $i in collection('sample.dbxml')/CustomerData/Transaction order by xs:decimal($i//ADR_PST_CD),xs:decimal($i//CLT_IRD_NBR) return $i", context);
XmlModify modify = manager.createModify();
XmlUpdateContext uc = manager.createUpdateContext();
XmlDocument xmldoc = container.getDocument("sample.xml");
XmlValue value = new XmlValue(xmldoc);
long numMod = modify.execute(value, context, uc);
System.out.println("Peformed " + numMod + " modification operations");
Could you point out the errors above or offer some suggestion?
Thanks.I have other question of the sorting issue. Here are a large XML need to sort so I have to split it to multiple small XML files. After importing these files, I will use the XmlModify and XQuery to sort them. I'm not clear on the multiple XML files processing.
1. Can the BDB XML ensure that all these XML files were sorted or how to update all documents with same logic.
2. If I want export all these sorted documents, how can I ensure these files processed in sequence? Which document needs process first?
The export method:
public void export(String outputfile)throws Exception{
final int BLOCK_SIZE = 5 * 1024 * 1024; // 5Mb
try{
File theFile = new File(outputfile);
FileOutputStream fos = new FileOutputStream(theFile);
byte[] buff= new byte[BLOCK_SIZE];
XmlResults rs = container.getAllDocuments(new XmlDocumentConfig());
while(rs.hasNext()){
XmlDocument xmlDoc = rs.next().asDocument();
XmlInputStream inputStream = xmlDoc.getContentAsXmlInputStream();
long read=0;
while(true){
read = inputStream.readBytes(buff, BLOCK_SIZE);
fos.write(buff,0,(int)read);
if(read < BLOCK_SIZE) break;
inputStream.delete();
xmlDoc.delete();
rs.delete();
//MUST CLOSE!
fos.close();
catch(Exception e){
System.err.println("Error exporting file from container " + container);
System.err.println(" Message: " + e.getMessage());
Thanks. -
Xml data into non-xml database.. solution anyone?
Hi,
My current project requires me to store the client's data on our servers. We're using Oracle9i. Daily, I will download the client's data for that day and load it into our database. My problem is that the data file is not a flat file so I can't use sql*loader to load the data. Instead, the data file is an xml file. What is the best way to load xml data into a non-xml database? Are there any tools similar to sql*Loader that will load xml data into non-xml database? Is it the best solution for the client to give me an XML dump of their data to load into our database, or should I request a flat file? My last resort would be to write some sort of a script to parse the xml data into a flat file, and then run it through sql*loader. Is this the best solution? One thing to note is that these files could be very large.
Thanks in advance.
-PVI assume that just putting the XML file into an
extremely large VARCHAR field is not what you want.
Instead, you want to extract data elements from the
XML and write them to columns in a table in your
database. Right?Yes. Your assumption is correct.
It sounds like you already have a script that loads a
flat file into your database. In that case I would
write an XSL transformation that converts the client's
XML into a correctly-formatted flat file.Thank you. I'll look into that. Other suggestions are welcome. -
Okay, as a heads up I work for a financial institution and we are converting our legacy "jetforms" to pdf format. I have in my staff for the project, 2 code developers and myself- a form designer. We have currently spent 2 months in trial and error attempting to resolve this problem, please let us know anything you can have. All client-side (internal) machines are running Windows XP and Adobe Reader 7.0.7
The software we use as a financial institution allows our users to export a customer's data file onto their machine which is then renamed to include the member's account number and first and last name for our staff to determine which data file they need more accurately. In legacy jetforms, we have developed a program that pushes the data from the customers file that they select, into the jetform that they want to open and the matching fields in the data file fill in the fields of the jetform. Clean and simple.
Now, i have hit nothing but frustration when attempting to perform the same process with pdfs using a form designed in livecycle designer 7. First, i see no obvious command for opening a pdf and importing a data file using a command line, like pdfmerge or something of the sort in which an xml data file can be specified and a pdf can be specified. I saw something like it using an fdf format and attempted to do this but apparently reader cannot import the data into the pdf that was designed adobe livecycle 7. All i have been seeing is database connections and using javascript inside the form to populate fields based on these database connections, etc. etc. or doing a manual file>import data>etc. which we don't want to have our staff do. We do not have reader extensions enabled, simply because i cannot get an adobe representative to call me and discuss pricing nor see any estimated pricing chart around. I don't know if reader extensions are necessary for this or not but i'm becoming very very frustrated with it.
We don't want a complex server-side data connection binding with dynamic input. No, we just want it where our developers can say "if this data file is selected, and this pdf form is selected run this command" which would be a simple pdfmerge type solution. Is this possible or do i need to stay with jetforms until our software the billion dollar financial institution uses does form building inside its own application? I don't want to fight about who is better, what version to use, etc. I just want the straight up honest truth. If you need to know the pricing that the reader extensions would have to go by, assume there will be 500 client computers that will need to use it.From your post it sounds like you are Central Pro (a product for which I am by no means an expert), but you say you want to upgrade to a newer product from your "legacy" one. Is there a reason for this? Have your requirements change so that it no longer fits them? Central is still in the current Adobe roster and as far as I know there is no plans to get rid of it any time soon, so if it does everything you want I don't see why you would want to change.
There is no product in the LiveCycle suite that merges xml data into a form from the command line. LiveCycle (with the exception of Designer) is a suite of server products, so the closest you would come is LiveCycle Forms (merge the xml and create a fillable PDF) or LiveCycle Print (merge the xml and print the form).
Hope this helps somewhat.
Chris
Adobe Enterprise Developer Support -
Tidy xml: clean xml data source form and characters
Hi,
the xml data set that I'd like to display with spry includes many special characters such as < and >, which are also used by xml to separate the individual data elements.
How can I replace those when the data are read, so that the data display correctly on my webpage. Currently any data set that has < or > characters is truncated.
I tried a replace function, but that did not work
function TidyXML(region, lookupFunc)
return TidyXML("{abstract}").replace(/\>/, ">");
return TidyXML("{abstract}").replace(/\</, "<");
Thanks for any help,
thorstenHi Phil
thanks for your fast reply.
The xml dataset is generated by Endnote, which is a database program
to organize scientific citations and which has unfortunately only very
limited xml functionality.
Thanks for the CDATA tipp, I will try that.
t.
Am 12.05.2009 um 21:34 schrieb Phil_W:
Hi,
>
You'll need to tidy up the XML file directly as I'd imagine browsers
such as Firefox and IE will not correctly read the XML dataset let
alone Spry Data XML.
>
Do you have the ability to edit the XML dataset / is it generated
from a database in the background?
>
Is the XML dataset online for us to see? Normal routine is to encode
the < > and other special characters when the XML file is generated
or to wrap the data within the XML tags in CDATA tags as below
>
<T_MESSAGE><![CDATA[Hi, <br /> <br /> Just a brief update on
Forum version 2 - currently in progress. <br /> <br /> It can
be seen here <br /> <br /> <a href="http://www.thehmc.co.uk/
forum2" target="_blank" title="http://www.thehmc.co.uk/forum2"
>Link1</a> <br /> <br /> It has some new features. <br />
<br /> 1. The default page allows you to navigate to all topics in
the forum. New posts / replies since your last visit are
highlighted. You can sort the posts / topics by clicking on the
headers, you can search topic subjects. It will automatically check
for new posts and update it's view every 30 seconds. No need to
click on refresh etc. <br /> <br /> 2. The topic pages show if
the person is online via a little green / red dot next to their
name. Layout changed to take full advantage of the website width. It
enables easier (and faster) navigation between the replies to a
post. <br /> <br /> 3. The new forum will natively recognise
youtube, google maps (new), images and links inserted into posts. No
need to put tags round them. <br /> <br /> For some good
examples of where the features are nifty see <br /> <br />
Google Maps <br /> <br /> <a href="http://www.thehmc.co.uk/forum2/topic.asp?ID=293&title=Chiltern%20Classic%20is
" target="_blank" title="http://www.thehmc.co.uk/forum2/topic.asp?ID=293&title=Chiltern%20Classic%20is
" >Link2</a> <br /> <br /> Topic Navigation <br /> <br />
<a href="http://www.thehmc.co.uk/forum2/topic.asp?ID=296&title=Weekend%204/5%20April
" target="_blank" title="http://www.thehmc.co.uk/forum2/topic.asp?ID=296&title=Weekend%204/5%20April
" >Link3</a> <br /> <br /> Let me know your thoughts on the new
look / features. <br /> <br /> Cheers <br /> <br />
Phil]]></T_MESSAGE>
>
Cheers
>
Phil
> -
[CS5.5/6] - XML / Data Merge questions & Best practice.
Fellow Countrymen (and women),
I work as a graphic designer for a large outlet chain retailer which is constantly growing our base of centers. This growth has brought a workload that used to be manageable with but two people to a never ending sprint with five. Much of what we do is print, which is not my forte, but is also generally a disorganized, ad-hoc affair into which I am wading to try to help reduce overall strain.
Upon picking up InDesign I noted the power of the simple Data Merge function and have added it to our repetoire in mass merging data sources. There are some critical failures I see in this as a tool going forward for our purposes, however:
1) Data Merge cannot handle information stored and categorized in a singular column well. As an example we have centers in many cities, and each center has its own list of specific stores. Data merge cannot handle a single column, or even multiple column list of these stores very easily and has forced us into some manual operations to concatenate the data into one cell and then, using delimiter characters, find and replace hard returns to seperate them.
2) Data Merge offers no method of alternate alignment of data, or selection by ranges. That is to say: I cannot tell Data merge to start at Cell1 in one column, and in another column select say... Cell 42 as the starting point.
3) Data merge only accepts data organized in a very specific, and generally inflexible pattern.
These are just a few limitations.
ON TO MY ACTUAL DILEMMA aka Convert to XML or not?
Recently my coworker has suggested we move toward using XML as a repository / delivery system that helps us quickly get data from our SQL database into a usable form in InDesign.
I've watched some tutorials on Lynda.com and havent yet seen a clear answer to a very simple question:
"Can XML help to 'merge' large, dynamic, data sets like a list of 200 stores per center over 40 centers based off of a single template file?"
What I've seen is that I would need to manually duplicate pages, linking the correct XML entry as I go rather than the program generating a set of merged pages like that from Data Merge with very little effort on my part. Perhaps setting up a master page would allow for easy drag and drop fields for my XML data?
I'm not an idiot, I'm simply green with this -- and it's kind of scary because I genuinely want us to proceed forward with the most flexible, reliable, trainable and sustainable solution. A tall order, I know. Correct me if I'm wrong, but XML is that beast, no?
Formatting the XML
Currently I'm afraid our XML feed for our centers isnt formatted correctly with the current format looking as such:
<BRANDS>
<BRAND>
• BrandID = xxxx
[Brand Name]
[Description]
[WebMoniker]
<CATEGORIES>
<CATEGORY>
• xmlns = URL
• WebMoniker = category_type
<STORES>
<STORE>
• StoreID = ID#
• CenterID = ID#
I dont think this is currently usable because if I wanted to create a list of stores from a particular center, that information is stored as an attribute of the <Store> tag, buried deep within the data, making it impossible to 'drag-n-drop'.
Not to mention much of the important data is held in attributes rather than text fields which are children of the tag.
Im thinking of proposing the following organizational layout:
<CENTERS>
<CENTER>
[Center_name]
[Center_location]
<CATEGORIES>
<CATEGORY>
[Category_Type]
<BRANDS>
<BRAND>
[Brand_name]
My thought is that if I have the <CENTER> tag then I can simply drag that into a frame and it will auto populate all of the brands by Category (as organized in the XML) for that center into the frame.
Why is this important?
This is used on multiple documents in different layout styles, and since our store list is ever changes as leases end or begin, over 40 centers this becomes a big hairy monster. We want this to be as automated as possible, but I'd settle for a significant amount of dragging and dropping as long as it is simple and straightforward. I have a high tollerance for druding through code and creating work arounds but my co-workers do not. This needs to be a system that is repeatable and understandable and needs to be able to function whether I'm here or not -- Mainly because I would like to step away from the responsibility of setting it up every time
I'd love to hear your raw, unadulterated thoughts on the subject of Data merge and XML usage to accomplish these sorts of tasks. What are your best practices and how would you / do you accomplish these operations?
Regards-
RobertFrom what I've gleaned through watching Lynda tutorials on the subject is that what I'm hoping to do is indeed possible.
Peter, I dont disagree with you that there is a steep learning curve for me as the instigator / designer of this method for our team, but in terms of my teammates and end-users that will be softened considerably. Even so I'm used to steep learning curves and the associated frustrations -- but I cope well with new learning and am self taught in many tools and programs.
Flow based XML structures:
It seems as though as long as the initial page is set up correctly using imported XML, individual data records that cascade in a logical fashion can be flowed automatically into new pages. Basically what you do is to create an XML based layout with the dynamic portion you wish to flow in a single frame, apply paragraph styles to the different tags appropriately and then after deleting unused records, reimport the XML with some specific boxes checked (depending on how you wish to proceed).
From there simply dragging the data root into the frame will cause overset text as it imports all the XML information into the frame. Assuming that everything is cascaded correctly using auto-flow will cause new pages to be automatically generated with the tags correctly placed in a similar fashion to datamerge -- but far more powerful and flexible.
The issue then again comes down to data organization in the XML file. In order to use this method the data must be organized in the same order in which it will be displayed. For example if I had a Lastname field, and a Firstname field in that order, I could not call the Firstname first without faulting the document using the flow method. I could, however, still drag and drop content from each tag into the frame and it would populate correctly regardless of the order of appearance in the XML.
Honestly either method would be fantastic for our current set of projects, however the flow method may be particularly useful in jobs that would require more than 40 spreads or simple layouts with huge amounts of data to be merged. -
XML data connection and XML submit button
Hi Guys,
another one that 'should' be straight forward. I have an xml data connection that is used ot pull in event details (name, location, cost etc) that allows you to select various events, then fill in your contact details and then submit the form. I need to have the form submit with the data that the user entered into the form as well as their selection of event. When I set up the email submit button, the XML file attached to the email is actually the XML file that the form pulls the event details from not the data that the user has entered into the form. Again I reckon this one should be straight forwad to fix, seems like a fairly normal way to operate, but I just cant find a solution. please help>We are letting user know that u have thrown email to someone and we also let user know how is going to contact them.
This is good, but you cannot stop the email from opening and the user
needing to send it. This is, as I said, fundamental to security and
cannot be switched off.
>I tried using HTTP request but it still opening email option to send mail.
This suggests you did not do it right, because when you use http, no
mail is sent locally. Can you describe what you do?
>
>I want to do the way we do in the html page using javascript to set action event at click event and send data to specified email id.
HTML cannot silently send an email either.
Perhaps you could outline what sort of HTML JavaScript you use, so
that we can suggest an equivalent if there is one.
Aandi Inston -
Build a table based on XML data set with Spry
Hi there,
I'm new to spry technology therefore forgive any basic question of mine.
I'm trying to fill content in a table based on XML data set values but nothing is shown :-(
here is my code.... any suggestion? pls tell me where I'm wrong.
Thank you in advance
<script src="SpryAssets/xpath.js" type="text/javascript"></script>
<script src="SpryAssets/SpryData.js" type="text/javascript"></script>
<script type="text/javascript">
var uscite = new Spry.Data.XMLDataSet("data/Calendario 2011.xml", "csv_data_records/record", {sortOnLoad: "Date", sortOrderOnLoad: "ascending"});
uscite.setColumnType("Date", "date");
uscite.setColumnType("km", "number");
</script>
<div class="RankContainer" id="UsciteDiv" spry:region="uscite" >
<table width="100%" border="0" class="RankTable">
<tr>
<th width="10%" scope="col" spry:sort="Date">Data</th>
<th width="20%" scope="col">Destinazione</th>
<th width="5%" scope="col">KM</th>
<th width="35%" scope="col">Percorso</th>
<th width="30%" scope="col">Breve</th>
<!-- <th width="15%" scope="col">Mappa</th>-->
</tr>
<tr>
<script type="text/javascript">
var rows = uscite.getData();
for (var i = 0; i < rows.length; i++)
if (rows[i]["Mappa"].startsWith("/"))
rowContent = "<td> si </td>";
else
rowContent = "<td> no </td>";
document.write("<td>{Date}</td>");
document.write("<td>"+rowContent+"</td>");
document.write("<td>{km}</td>");
document.write("<td>{Percorso}</td>");
document.write("<td>{Breve}</td>");
</script>
</tr>
</table>
</div>Sure this is how it should work (except that no anchor tag shall be present for Destinazione whereas Mappa has no real value in)
http://www.gsc-borsano.it/_Calendario%202011.html
and this is the non working page
http://www.gsc-borsano.it/_v2Calendario%202011.html
Thanks -
Spry XML Data won't diplay - Help
Here is my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml"
xmlns:spry="
http://ns.adobe.com/spry">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
left:8px;
top:27px;
width:266px;
height:115px;
z-index:1;
-->
</style>
<script language="JavaScript" src="SpryAssets/xpath.js"
type="text/javascript"></script>
<script src="SpryAssets/SpryData.js"
type="text/javascript"></script>
<script type="text/javascript">
<!--
var dsEvent = new Spry.Data.XMLDataSet("events.xml",
"events/event");
//-->
</script>
</head>
<body>
<div id="apDiv1">
<div spry:region="dsEvent">
<table width="278" >
<tr>
<th>Name</th>
<th spry:sort="location">Location</th>
</tr>
<tr spry:repeat="dsEvent" spry:setrow="dsEvent">
<td>{name}{date}</td>
<td>{location}</td>
</tr>
</table>
</div>
</div>
</body>
</html>
Here is my problem:
If I use UNC path it display the data.
If I use IIS --- such as http:\\testServer\devhome\test.cfm
it will give me a blank white page. No xml data.
Can any one point me out what I am doing wrong?
Thanks in advance.Here is my new finding : After I changed ".cfm" to ".html"
--- it work's !!!!!!!!!!
My new question is why it is not working in coldfusion. I
tried in two diffrent server --- same result.
Need some help here.
Thanks in Advance. -
Custom Sort (by date) in a DataGrid component
So I've got a data grid component hooked up to a data provider like so:
var weekData:XML=// some xml loaded in earlier....
var weekGrid:DataGrid=new DataGrid();
var dataProvider:DataProvider=new DataProvider();
for each(var entry:XML in weekData){
dp.addItem({event:entry.title,date:FormatDate.format(new Date(entry.@startDate),5),data:entry.@startDate});
The title column is just what you might think. The date colum is actually a format like May 2012 or Feb 2013. And the data "column" isn't actually shown in the dataGrid it is the "key" for sorting by date. It contains the getTime() value of the date like 1328515200000. So that will make date sorting just a case of Array.NUMERIC with the appropriate Array.DESCENDING when needed.
I've found that if I do this:
weekGrid.dataProvider.sortOn("data",Array.NUMERIC)
weekGrid.invalidate();
it works and the grid is sorted -- IF I have some other button to click to cause that code to run.
I want to tie it together with the click event on the grid header. Thusly:
weekGrid.addEventListener(DataGridEvent.HEADER_RELEASE,sortDataGrid);
And I've getting the event and all, but evidently that is fireing off the built-in sorting which happens after mine. And it doesn't do what I want.
Any idea how to stop that and allow my perferred sorting to take place?if you don't want the user to sort your datagrid, use:
weekGrid.sortableColumns = false;
and execute your sort without clicking anything. or use:
weekGrid.addEventListener(DataGridEvent.HEADER_RELEASE,sortDataGrid);
function sortDataGrid(e:DataGridEvent):void{
setTimeout(sortF,100);
function sortF():void{
weekGrid.dataProvider.sortOn("data",Array.NUMERIC) -
Spry xml data set, accessing specific rows
Hello. I've been trying to build a website using Spry XML
Data Sets, and while I've accomplished my goals for now, I don't
think the solution I came up with is the best.
The website consists of several areas that show projects.
Each project has several fields that are to be filled with content
retrieved from the xml files, but the projects are not all exactly
alike and some have specific fields that others don't require.
All the info is available in several languages, so for now
I've created an xml file for each one. An xml file could be like
Code Part1. (Why I can't add several code snippets along the post
baffles me. I mean, I can't, right?)
This dataset, for simplicity purposes, is not dependent on
the language (Code Part2).
And then there are the content areas (Code Part3).
So as you see, each project has its own structure. This makes
using spry:repeat a not very effective method for filling in all
the content. Ideally I should be able to access each row in the
dataset through some sort of value, like id, or one of its
children's values. The ds_RowID depends on the row order, so unless
there's another way to use it, it doesn't solve my problem.
Here's what I've come up with (Code Part4).
This works (in FF3 OSX, at least), although there are some
other problems that might make it necessary to create a spry:region
(or at least use spry:repeat) for each field. Anyway, it sounds
silly and wasteful to go through every row of the dataset everytime
for each of the fields that need to be filled.
My hope is that I'm ignorant of some much better method of
achieving my goals, something more direct and elegant.
Can anyone help me out with this? Thank you very much in
advance.Hi there
You are indeed absolutely correct a spry region should have been shown, my appologise for that, the code is wrapped in a standard spry region.
That being said i have used a work around in the SQL SELECT statement of the xmlExportObj, Recordset to find the information required without having to do any IF, ELSE on the page.
Many thanks for your reply and for pointing out my mistake in how I had presented my question.
My next question is to follow seperately
Regards
Ray -
XML data output file in a directory needs to be published as a pdf report
Hi,
I have already got an XML output file in a directory.
I want to display it using RTF template using a concurrent program or some sort of java api in a pdf format to be able to print it.
How do I do it? Do I have to write another file output command to read the xml data line by line and output to BI publisher first?Hi,
Hmm, one way is to just utl_file read the file and fnd_file.put_line(fnd_file.output) then close the file. Setup conc prog, rtf template, data definition and you're done.
But the main thing is that you get the XML file to $APPLCSF/$APPLOUT/oXXXXX.out where XXXXX is the request id. You could just setup host concurrent program and copy the file there!
Regards,
Gareth
Blog: http://garethroberts.blogspot.com/
Message was edited by:
gareth.roberts
Message was edited by:
gareth.roberts -
XML data with nested repeating nodes
First let me prelude with my skill set; "I am an XML,
JavaScript and Spry newbie". My xml data looks like this:
<report>
<header>
<column type="[string|real|int]>some
value</column>
<column type="[string|real|int]>some
value</column>
</header>
<details>
<row>
<cell type="[string|real|int]">some value</cell>
<cell type="[string|real|int]">some value</cell>
</row>
<row>
<cell type="[string|real|int]">some value</cell>
<cell type="[string|real|int]">some value</cell>
</row>
</details>
</report>
- report/header/column is completely dynamic and not known in
advance
- each report/header/column is the table column name value
- each report/details/row/cell is the table cell value
- type="[string|real|int]" is data type of the cell value
Using Spry 1.5 I have been able to successfully populate the
table column header row dynamically and repeat the appropriate
number of rows.
Spry is Cool!
I have not been able to figure out how to repeat
report/details/row/cell for each repeating row node. If I nest
spry:repeat it appears to go into an endless loop.
I will also need to equate data type to a Spry data type so
that I may sort the columns appropriately for their respective data
type.
Here is the code I have so far:
<script language="JavaScript" type="text/javascript"
src="includes/xpath.js"></script>
<script language="JavaScript" type="text/javascript"
src="includes/SpryData.js"></script>
<script language="JavaScript" type="text/javascript"
src="includes/SpryNestedXMLDataSet.js"></script>
<script type="text/javascript">
var dsReport = new
Spry.Data.XMLDataSet("data/cmbcov_raw.xml", "/iqreport");
var dsHeaders = new Spry.Data.NestedXMLDataSet(dsReport,
"header/column");
var dsRows = new Spry.Data.NestedXMLDataSet(dsReport,
"details/row");
var dsCells = new Spry.Data.NestedXMLDataSet(dsReport,
"details/row/cell");
Spry.Data.Region.debug = true;
</script>
<link href="/report/css/samples.css" rel="stylesheet"
type="text/css" media="all" />
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Reports</title>
</head>
<body>
<h3
spry:region="dsReport">{dsReport::@title}</h3>
<div class="liveSample" spry:region="dsReport dsHeaders
dsRows dsCells">
<table class="dataTable">
<tr>
<th
spry:repeat="dsHeaders">{dsHeaders::column}</th>
</tr>
<tbody>
<tr spry:repeat="dsRows">
<td>{dsCells::cell}</td> <!--if I use
spry:repeat here browser hangs - endless loop?-->
</tr>
</tbody>
</table>
</div>
</body>
</html>
Your assistance will be greatly appreciated!
Thank you in advance,
nomadcanuckDon,
Thanks for forcing me to read the nested data set sample
again, three times the charm as they say :). I made the following
addition to get it to work.
var dsDetails = new Spry.Data.NestedXMLDataSet(dsReport,
"details");
var dsRows = new Spry.Data.NestedXMLDataSet(dsDetails,
"row");
var dsCells = new Spry.Data.NestedXMLDataSet(dsRows, "cell");
<tbody spry:repeat="dsDetails">
<tr spry:repeat="dsRows">
<td spry:repeat="dsCells">{dsCells::cell}</td>
</tr>
</tbody>
I am still stumped with respect to sorting the dynamic
header/column. Any chance of being pointed in the right direction,
either document or hint is appreciated.
Thanks again,
nomadcanuck -
Spry tables: Sort by date
I need a spry table to sort by title and date columns; the
title works fine by selecting the 'sortable column' option when
making the table - this didn't work for the date column, but I
think this was because the excel/xml data used had the date info in
a text format. Once I'd formatted the date column cells in excel
doc as 'date' in (e.g.) Jan-07 format, the xml conversion changed
the data to what i think is the standard date format (e.g.
2007-07-01 00:00:00). Making this column sortable resulted in rows
being rearranged in the spry table, but not in any logical order.
please help!
many thanks,
S
(apologies if that was long-winded, wasn't sure whether you
needed any context)You cannot sort a formatted date by default using the Spry. How is the data stored, in XML or HTML? And is the date stored as a formatted date or a timestamp? What is typically suggested is that you store the dates in two formats. First is a timestamp format or a formatted date as yyyy-mm-dd. You use that column to sort and then you have a date formatted however you want in a second column and that gets displayed to the user.
You can see more about this in the following thread: http://forums.adobe.com/thread/85718
The problem with the dd/mm/yy format is that Spry (and many other solutions) read the information as plain text. So here's a quick example of oldest to newest
30122011 - Dec 30, 2011
31012011 - Jan 31, 2011 - January would come after Dec
01302011 - Jan 31, 2011
01312010 - Jan 30, 2010 - 2011 would be before 2010
20100131 - Jan 31, 2010
20110131 - Jan 31, 2011
20111230 - Dec 30, 2011 - In this format all numbers show up in numerical order. -
I have a php form that when processed, opens an existing xml
file and writes to the end of it:
<code>
$file_handle = fopen('products.xml','a');
$content=(
<new product>
<date>{$_POST['date']}</date>
<name>{$_POST['name']}</name>
<price>{$_POST['price']}</price>
</new product>
fwrite($file_handle,$content);
fclose($file_handle);
</code>
Each week, a new date (formatted as mm/dd/yyyy), product and
price is added to this master xml list. The list is large and
contains a weekly input for date, product name and price going back
to 2004. To display the master list on the web, I am using a Spry
Data table with the sort function enabled:
<code>
var products = new Spry.Data.XMLDataSet("products.xml",
"/products/newproduct");
products.setColumnType("date", "name", "price");
function DoSort()
products.sort(["date", "name", "price"], "toggle");
-->
</script>
</head>
<body>
<h3>Display and Sort All Products</h3>
<div spry:region="products">
<table>
<tr>
<th spry:sort="date">Date</th>
<th spry:sort="name">Product Name</th>
<th spry:sort="price">Price</th>
</tr>
<tr spry:repeat="products">
<td>{date}</td>
<td>{name}</td>
<td>{price}</td>
</tr>
</table>
</div>
</code>
Everything works perfectly, except that by default, the xml
data is being displayed "top-down" so that the first item is in
2004, with the last item being the current weekly input for 2008. I
would like the table (by defuault or on load) to display the xml
data "bottom-up" so that the most recent input is always at the
top.
Can someone please help me figure out how to do this? I have
looked for the answer everywhere, but can't seem to find a
solution.A other thing u could do is sort the region on postLoad the
first time..
First create a global variable something like:
var productsLoaded = false;
than add a observer to your dataset..
products.addObserver({onPostLoad:function(){
if(!productsLoaded){
productsLoaded = true;
DoSort();
so.. total code:
var products = new Spry.Data.XMLDataSet("products.xml",
"/products/newproduct");
var productsLoaded = false;
products.setColumnType("date", "name", "price");
function DoSort()
products.sort(["date", "name", "price"], "toggle");
products.addObserver({onPostLoad:function(){
if(!productsLoaded){
productsLoaded = true;
DoSort();
}});
Maybe you are looking for
-
Trying to update iTunes. It downloades OK but when installing it ask for a CD or DVD that I don't have. I have been updating for several years with no problems I updated the software on the iPod touch and now it won't work with the version iTunes i h
-
ITunes on my new Mac is telling me paid for music "not available in iTunes store"?
I have had an iTunes account for years. Having just bought a Mac and synced iTunes, selected tracks on many of my iTunes store purchased albums are missing - e.g. tracks 2,3,4,7 & 11- iTunes says "This album is not currently available in the iTunes
-
Sort open items without +/- sign
Hi SAP Experts, i would like to display the open items without +/- sign when i will try to sort. it is possible in edit options in while clearing. but when i will try to display the open items i can not get that option. i have tried with t.code - fb0
-
Can't start reports server on Windows Server 2003 SP1 Error code 13
Hi, This morning I figured how to start the rwserver using the command, rwserver server = repsrv. This works using XP pro physical machine but now I am trying to perform the same task on a Windows 2003 virtual machine. I have used the line: rwserver
-
Dear Fnds, When iam using Configurable material in Sales order, Avl Check is not Carrying out. Configuration is: I maintained Avl check in Material master 02(_individual Requirement_) Strategy group is 025 In this Stra