Difficulty parsing XML document into query object
Background: Using CFMX 6.1 to take an XML file exported from
MS-Access and parse it into a query object.
Problem: Of the 6 columns defined in the target query, one of
the columns is only populated in the XML file a very low percentage
of the time. When trying to populate the column for a record that
has no volume I was getting the following error:
Element KEY6.XMLTEXT is undefined in a Java object of type
class coldfusion.xml.XmlNodeMap referenced as...
To get around this I made this code change:
Before
<cfset temp = QuerySetCell(mcquery, "CuKey6",
#mydoc.root.dataroot.qTop1000
.Key6.XmlText#, #i#)>
After
<cfif
StructKeyExists(mydoc.root.dataroot.qTop1000.XMLAttributes,"Key6")>
<cfset temp = QuerySetCell(mcquery, "CuKey6",
#mydoc.root.dataroot.qTop1000
.Key6.XmlText#, #i#)>
</cfif>
The new code gets around the error, but when the template is
executed, columns that DO have values
show up as "[empty string]".
I am trying to figure out why when the record has a actual
value it is now overwritten instead of populated
normally?
Use XmlChildren[1], XmlChildren[2],... etc., in place of
Key1, Key2, etc.
Similar Messages
-
Parsing XML document with nested elements into multiple db tables(master-detail)
Can you help me with storing xml document into master-detail tables?
I have two tables:
1) customers (customerid number primary key, firstname varchar2(30),lastname varchar2(30))
2) cust_addresses (customerid number references customers, street varchar2(30),city varchar2(30),state varchar2(10),zip varchar2(10))
I have XML document:
<?xml version="1.0"?>
<ROWSET>
<ROW num="1">
<CUSTOMERID>1044</CUSTOMERID>
<FIRSTNAME>Paul</FIRSTNAME>
<LASTNAME>Astoria</LASTNAME>
<HOMEADDRESS>
<STREET>123 Cherry Lane</STREET>
<CITY>SF</CITY>
<STATE>CA</STATE>
<ZIP>94132</ZIP>
</HOMEADDRESS>
<HOMEADDRESS>
<STREET>N.Fryda 4</STREET>
<CITY>CB</CITY>
<STATE>CZ</STATE>
<ZIP>37005</ZIP>
</HOMEADDRESS>
</ROW>
</ROWSET>
I know that I must use DBSM_XMLSave package, create view and instead of trigger but I did found no example in documentation.
Thanx.Interested question; one I do not know the answer to at the moment, I am afraid. I would like to know your results.
To tell others, though, what I have done. I did finally adapt Muench's not-yet-published examples #71 to work with a table. Here the table has as it's value "#{backing_app_EPG_DAYPG.jobDayDriverTable[row.Id1]}"
This accesses a hash map defined in the backing bean as follows:
public Map jobDayDriverTable = new HashMap(){
@Override
public Object get(Object key) {
Number jobDayId = (Number)key;
if (getEpgDayPage().jobDayDrivers(jobDayId) != null) {
return getEpgDayPage().jobDayDrivers(jobDayId).getAllRowsInRange();
else return null;
jobDayDrivers returns RowIterator. From this I call getAllRowsInRange which returns a Row[]. The table consumes this as a value, and lists the values as I want.
Since the table is using Rows for its rows, I am guessing that it would have access to #{row.rowKeyStr}, or at least #{row.<pk>} which would allow you to programmatically set the current row using code like the following:
public static boolean setCurrentRow() {
// BindingContainer bindings = getBindings();
OperationBinding operationBinding =
// bindings.getOperationBinding("setCurrentRowWithKey");
(OperationBinding)EL.get("#{bindings.setCurrentRowWithKey}");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return false;
return true;
You could call this as part of code in a pages backing bean behind a button or link.
Hope this helps somebody.
By the way example #71 was to get a detail set of rows from a master row value and display the detail set in the master row of an af:table.
You can find this and other examples at http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html -
To load an XML document into 40 tables
How do I load a large XML document into 40 tables. Most of the exmaples, I see only load one table into the Orcale database?
From the above document:
Storing XML Data Across Tables
Question
Can XML- SQL Utility store XML data across tables?
Answer
Currently XML-SQL Utility (XSU) can only store to a single table. It maps a canonical representation of an XML document into any table/view. But of course there is a way to store XML with the XSU across table. One can do this using XSLT to transform any document into multiple documents and insert them separately. Another way is to define views over multiple tables (object views if needed) and then do the inserts ... into the view. If the view is inherently non-updatable (because of complex joins, ...), then one can use INSTEAD-OF triggers over the views to do the inserts.
-- I've tried this, works fine. -
Can I append an XML Document into another?
I have a large xml document which I open into coldfusion (mx
7), and then a smaller group of files that are opened into thier
own xml objects. After some customization of xml text values, I
want to append the smaller xml documents into the larger document
at specific positions within the document tree.
I have the code that I thought would do this, using an
arrayappend function, but what happens is that only the root
element of the smaller (inserted) xml document is placed into the
main document.
Is this possible, or do I need to modify the code so that the
entire tree of xml data that I am appending is created on the
fly?Personally I do this with XSLT.
<cfxml variable="doc1">
<root>
<member id="10">
<name>Ian</name>
<sex>male</sex>
</member>
</root>
</cfxml>
<cfxml variable="doc2">
<root>
<member id="1">
<name>Joe</name>
<sex>male</sex>
</member>
<member id="2">
<name>John</name>
<sex>male</sex>
</member>
<member id="3">
<name>Sue</name>
<sex>female</sex>
</member>
</root>
</cfxml>
<cffile action="write" file="#expandPath("/")#\doc2.xml"
output="#ToString(doc2)#" nameconflict="overwrite">
<!--- METHOD ONE using a depreciated and undocumented
method --->
<cfset newNode = doc1.root.member.cloneNode(true)>
<cfset doc2.changeNodeOwner(newNode)>
<cfset doc2.root.appendChild(newNode)>
<cfdump var="#doc2#" label="Merged by hidden functions"
expand="no">
<!--- METHOD TWO using XSLT --->
<!--- create an xsl docutment--->
<cfoutput>
<cfsavecontent variable="transformer">
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml"/>
<!--load the merge file -->
<xsl:variable name="emps"
select="document('#expandPath("/")#\doc2.xml')"/>
<!--- this line references and XML file to be combined
with the main file,
I wonder if there is a way to use an XML document in memory
here? --->
<!-- combine the files -->
<xsl:template match="/">
<root>
<!-- select all the child nodes of the root tag in the
main file -->
<xsl:for-each select="root/child::*">
<!-- copy the member tag -->
<xsl:copy-of select="."/>
</xsl:for-each>
<!-- and all the child nodes of the root tag in the merge
file -->
<xsl:for-each select="$emps/root/child::*">
<!-- copy the member tag -->
<xsl:copy-of select="."/>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
</cfsavecontent>
</cfoutput>
<!--- create a combined xml document --->
<cfset doc2 = XMLparse(XMLtransform(doc1,transformer))>
<cfdump var="#doc2#" label="Merged by XSLT"
expand="no"> -
Parse XML document which have xlink/xpointer inside
dear friends,
There are lots of topic talking about parse xml, validating xml with schema and so on, but no one or any book talking about parsing xml document which can parse document with link inside.
According to Mr Meggison at http://www.megginson.com/Background/
we can do it, but he is not expert with this thing.
For example I have 3 XML document. My main XML document, let named it A.XML have XPointer inside and this element pointing to B.XML and C.XML using xpointer. how to parse A.XML and in the same time my SAX recognized this XPointer and parse also element inside B.XML and C.XML.
I am really grateull for any helpful information from you.
best regardsI think you need to look for a SAX or DOM parser that undestands XPointers and knows how to follow them to additional content.
I have used XSLT and specified external documents to it. It knows how to read a document and in effect make a nodeset which can be searched with the XPath capabilities of XSLT.
It sounds like you wnat an <include file="xxx"/> capability and have the parser stop reading the current file, and start reading the second file.
That works in Schemas, but I'm unaware of any way to do it with SAX or DOM in one pass.
It would not be too hard to process the first file, say with DOM.
After the Document is built, go find the <include> elements, read get the attribute needed, build a new Document and merge it into the original Document in place of the <include> element.
Is this more what you want to do?
Dave Patterson -
Got error message when store XML documents into XML DB repository, via WebD
Hi experts,
I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
I got error message when store XML documents into XML DB repository, via WebDAV.
I have successfully registered 5 related schemas and generated 1 table.
I have inserted 40 .xml files into this auto generated table.
using these data I created relational view successfully.
but since I couldn't store XML documents into XML DB repository, via WebDAV
when I query using below code:
SELECT rv.res.getClobVal()
FROM resource_view rv
WHERE rv.any_path = '/home/DEV/messages/4fe1-865d-da0db9212f34.xml';
I got nothing.
My ftp code is listed below:
ftp> open localhost 2100
Connected to I0025B368E2F9.
220- C0025B368E2F9
Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
220 I0025B368E2F9 FTP Server (Oracle XML DB/Oracle Database) ready.
User (I0025B368E2F9:(none)): fda_xml
331 pass required for FDA_XML
Password:
230 FDA_XML logged in
ftp> cd /home/DEV/message
250 CWD Command successful
ftp> pwd
257 "/home/DEV/message" is current directory.
ftp> ls -la
200 PORT Command successful
150 ASCII Data Connection
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 .
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 ..
226 ASCII Transfer Complete
ftp: 115 bytes received in 0.00Seconds 115000.00Kbytes/sec.
250 SET_CHARSET Command Successful
ftp> put C:\ED\SPL\E_Reon_Data\loaded\4fe1-865d-da0db9212f34.xml
200 PORT Command successful
150 ASCII Data Connection
550- Error Response
ORA-00600: internal error code, arguments: [qmxConvUnkType], [], [], [], [], [], [], [], [], [], [], []
550 End Error Response
ftp: 3394 bytes sent in 0.00Seconds 3394000.00Kbytes/sec.
I have tried all suggestion from another thread such as:
alter system set events ='31150 trace name context forever, level 0x4000'
SQL> alter system set shared_servers = 1;
but failed.
is there anyone can help?
Thanks.
Edited by: Cow on Mar 29, 2011 12:58 AMHi experts,
I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
I got error message when store XML documents into XML DB repository, via WebDAV.
I have successfully registered 5 related schemas and generated 1 table.
I have inserted 40 .xml files into this auto generated table.
using these data I created relational view successfully.
but since I couldn't store XML documents into XML DB repository, via WebDAV
when I query using below code:
SELECT rv.res.getClobVal()
FROM resource_view rv
WHERE rv.any_path = '/home/DEV/messages/4fe1-865d-da0db9212f34.xml';
I got nothing.
My ftp code is listed below:
ftp> open localhost 2100
Connected to I0025B368E2F9.
220- C0025B368E2F9
Unauthorised use of this FTP server is prohibited and may be subject to civil and criminal prosecution.
220 I0025B368E2F9 FTP Server (Oracle XML DB/Oracle Database) ready.
User (I0025B368E2F9:(none)): fda_xml
331 pass required for FDA_XML
Password:
230 FDA_XML logged in
ftp> cd /home/DEV/message
250 CWD Command successful
ftp> pwd
257 "/home/DEV/message" is current directory.
ftp> ls -la
200 PORT Command successful
150 ASCII Data Connection
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 .
drw-r--r-- 2 FDA_XML oracle 0 DEC 17 19:19 ..
226 ASCII Transfer Complete
ftp: 115 bytes received in 0.00Seconds 115000.00Kbytes/sec.
250 SET_CHARSET Command Successful
ftp> put C:\ED\SPL\E_Reon_Data\loaded\4fe1-865d-da0db9212f34.xml
200 PORT Command successful
150 ASCII Data Connection
550- Error Response
ORA-00600: internal error code, arguments: [qmxConvUnkType], [], [], [], [], [], [], [], [], [], [], []
550 End Error Response
ftp: 3394 bytes sent in 0.00Seconds 3394000.00Kbytes/sec.
I have tried all suggestion from another thread such as:
alter system set events ='31150 trace name context forever, level 0x4000'
SQL> alter system set shared_servers = 1;
but failed.
is there anyone can help?
Thanks.
Edited by: Cow on Mar 29, 2011 12:58 AM -
How to convert Xml Document into orcale tempary table
i am creating xml document into java and passing this xml into oracle database and i need to fetch this xml into result set | rowset.
Xml Structure
<Department deptno="100">
<DeptName>Sports</DeptName>
<EmployeeList>
<Employee empno="200"><Ename>John</Ename><Salary>33333</Salary>
</Employee>
<Employee empno="300"><Ename>Jack</Ename><Salary>333444</Salary>
</Employee>
</EmployeeList>
</Department>
i need like this format
Deptno DeptName empno Ename Salary
100 Sports 200 Jhon 2500
100 Sports 300 Jack 3000It does depend on your version as odie suggests.
Here's a way that will work in 10g...
SQL> ed
Wrote file afiedt.buf
1 with t as (select xmltype('<Department deptno="100">
2 <DeptName>Sports</DeptName>
3 <EmployeeList>
4 <Employee empno="200"><Ename>John</Ename><Salary>33333</Salary>
5 </Employee>
6 <Employee empno="300"><Ename>Jack</Ename><Salary>333444</Salary>
7 </Employee>
8 </EmployeeList>
9 </Department>
10 ') as xml from dual)
11 --
12 -- End of test data, Use query below
13 --
14 select x.deptno, x.deptname
15 ,y.empno, y.ename, y.salary
16 from t
17 ,xmltable('/'
18 passing t.xml
19 columns deptno number path '/Department/@deptno'
20 ,deptname varchar2(10) path '/Department/DeptName'
21 ,emps xmltype path '/Department/EmployeeList'
22 ) x
23 ,xmltable('/EmployeeList/Employee'
24 passing x.emps
25 columns empno number path '/Employee/@empno'
26 ,ename varchar2(10) path '/Employee/Ename'
27 ,salary number path '/Employee/Salary'
28* ) y
SQL> /
DEPTNO DEPTNAME EMPNO ENAME SALARY
100 Sports 200 John 33333
100 Sports 300 Jack 333444
SQL>If the XML is a string e.g. a CLOB then it can easily be converted to XMLTYPE using the XMLTYPE function. -
How to parse xml data into java component
hi
everybody.
i am new with XML, and i am trying to parse xml data into a java application.
can anybody guide me how to do it.
the following is my file.
//MyLogin.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
class MyLogin extends JFrame implements ActionListener
JFrame loginframe;
JLabel labelname;
JLabel labelpassword;
JTextField textname;
JPasswordField textpassword;
JButton okbutton;
String name = "";
FileOutputStream out;
PrintStream p;
Date date;
GregorianCalendar gcal;
GridBagLayout gl;
GridBagConstraints gbc;
public MyLogin()
loginframe = new JFrame("Login");
gl = new GridBagLayout();
gbc = new GridBagConstraints();
labelname = new JLabel("User");
labelpassword = new JLabel("Password");
textname = new JTextField("",9);
textpassword = new JPasswordField(5);
okbutton = new JButton("OK");
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 1;
gbc.gridy = 5;
gl.setConstraints(labelname,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 2;
gbc.gridy = 5;
gl.setConstraints(textname,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 1;
gbc.gridy = 10;
gl.setConstraints(labelpassword,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 2;
gbc.gridy = 10;
gl.setConstraints(textpassword,gbc);
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridx = 1;
gbc.gridy = 15;
gl.setConstraints(okbutton,gbc);
Container contentpane = getContentPane();
loginframe.setContentPane(contentpane);
contentpane.setLayout(gl);
contentpane.add(labelname);
contentpane.add(labelpassword);
contentpane.add(textname);
contentpane.add(textpassword);
contentpane.add(okbutton);
okbutton.addActionListener(this);
loginframe.setSize(300,300);
loginframe.setVisible(true);
public static void main(String a[])
new MyLogin();
public void reset()
textname.setText("");
textpassword.setText("");
public void run()
try
String text = textname.getText();
String blank="";
if(text.equals(blank))
System.out.println("First Enter a UserName");
else
if(text != blank)
date = new Date();
gcal = new GregorianCalendar();
gcal.setTime(date);
out = new FileOutputStream("log.txt",true);
p = new PrintStream( out );
name = textname.getText();
String entry = "UserName:- " + name + " Logged in:- " + gcal.get(Calendar.HOUR) + ":" + gcal.get(Calendar.MINUTE) + " Date:- " + gcal.get(Calendar.DATE) + "/" + gcal.get(Calendar.MONTH) + "/" + gcal.get(Calendar.YEAR);
p.println(entry);
System.out.println("Record Saved");
reset();
p.close();
catch (IOException e)
System.err.println("Error writing to file");
public void actionPerformed(ActionEvent ae)
String str = ae.getActionCommand();
if(str.equals("OK"))
run();
//loginframe.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}hi, thanks for ur reply.
i visited that url, i was able to know much about xml.
so now my requirement is DOM.
but i dont know how to code in my existing file.
means i want to know what to link all my textfield to xml file.
can u please help me out. i am confused.
waiting for ur reply -
Open .xml documents into InDesign?
Is there a way to open .xml documents into InDesign, or any Adobe program?
The goal is to access text from a web site feed and place it in an Indesign doc, to create a print product.You can't open XML but you can certainly utilize it.
Here's a good book you might want to look into: http://amzn.to/i3iWZ5
Bob -
XML document into multiple tables
How to insert a xml document into multiple tables. Eg. Purchase Order having multiple line items. I have to insert xml document into Parent as well as child with different sets of columns.
I created the tables using the create_ch14_tables.sql. I call it using java -classpath .;C:\commerceone\xpc\lib\xmlparserv2.jar;C:\commerceone\xpc\lib\classes12.zip;C:\commerceone\xpc\lib\xsu12.jar XMLLoader -file deptempdepend.xml -connName default -transform deptempdepend.xsl. The code doesn't seem to like the "<xsl:for-each select="Department">" tags. If I remove them, the insDoc.getDocumentElement().getFirstChild() will find the element, but it still doesn't insert anything into the database.
Thank You,
Dave -
Existing XML documents into KM
Hello Everyone
Is there a way to load existing xml documents into KM and then maintain them using xml forms built using the form builder. Any help is greatly appreciated.
Thanks
SwethaHi Renuka
You can move the XML projects from one server to another.The Xml forms created is stored in the path 'etc\xmlforms' in KM. You can send it out and Upload to the target server instead of creating the same in the Target server from the scratch.
Regards
Geogi -
Exception when inserting a XML document into database
Hello.
I'm trying to insert the content of a XML document into a database. The problem consists on the exception that is raised when a FK in the XML is not in the database as a PK
How can i catch these exceptions and continuing inserting the rest of the data
Thanks in advance ...I really hope for you this wasn't a production database, as mentioned in the URL, it has been some years ago for me fiddling around this which was btw a supported metalink workaround ONCE (during my Oracle 7 days), but now, I wouldn't be surprised if you now have mixed NLS content in your tables/database and more or less "corrupted" your content.
The initial issue was probably a client one.
BTW
I actually hope it was a production database, maybe then you would learn that way, that you SHOULD NEVER EVER UPDATE DATABASE BASE TABLES directly...
...unless (the only exception) you want to learn something about the internals and don't care that your TEST database gets corrupted.... -
How to ftp XML document into a XML type which is not created by itself.
Hi,
1.
I have a table call SNPLEX_DESIGN which is created automaticly when I register a snplex_design.xsd XML schema.( Oracle creates it through the xdb:defaultTable="SNPLEX_DESIGN attribute). and it is created using SNPLEX user account.
2.
I also created a folder (resource) call /home/SNPLEX/Orders. which is used to hold all the incoming XML document.
3.
I created another user account call SNPLEX_APP, which is the only user account allowed to FTP XML document into /home/SNPLEX/Orders folder.
Isuues,
If I login as SNPLEX user, I can ftp XML document into the folder and TABLE (the file size = 0). But If I login as SNPLEX_APP user account, I can only ftp XML document into the folder, but Oracle doesn't store the document into the table( becuase the files size shows a number).
I have granted all the ACL privileges on the /home/SNPEX/Orders folder to SNPLEX_APP hrough OEM.
DO I miss anything. Any helps will be great appreciated. Resolve this issues is very import to us, sicne we are on a stage to roll system into production.
Regards,
JinsenIN order for a registered schema to be available to other users the schema must be registered as a GLOBAL, rather than a LOCAL Schema. This is controlled by the third agument passed to registerSChema, and the default is local. Note that you will also need to explicity grant appropriate permissions on any tables created by the schema registration process to other users who will be loading or reading data from these tables.
-
Possible to combine two xml documents into a single query?
In ASP, PHP, etc. if I wanted to combine two tables and
filter by one =
item, I would create a recordset combining the two on one
common element =
and have one recordset. Is that possible with xml documents
and Spry =
datasets?
I have xml information sent to me 4 times a day from a
weather service. =
This happens automatically, but the two xml documents
(current.xml and =
forecast.xml) are set in stone by the service. However, if in
my Spry =
dataset, I could combine them so I could list the 15 cities
in a master =
region and have tabs for the current conditions and forecast
which would =
each access a separate xml document but needs to do that from
the city =
link on the left, that would work great.
Can I do this as I would be able to if I had a database with
different =
tables?
Thanks!
NancyHi Kin:
They are really static xml files that are placed in a folder
directly by =
the weather service. The files in question are current.xml
and =
forecast.xml.
And there is not one per city .. but just one of each. the
location =
node in current.xml and the citycode node in forecast.xml
contain the =
same information.
If I were doing this in a recordset with a database, I would
write =
something like SELECT whatever from current, forecast WHERE =
current.location =3D forecast.citycode AND current.location
=3D variable =
(which would be what is clicked on).
This sets up a master/detail arrangement for the first one
that works =
fine. Click on the city code (which I have to write something
to say If =
location =3D FAT, document.write "Fresno" and so on) and the
rest of the =
current information displays fine on the right side of the
page. Now I =
have to marry that to the forecast.xml file so that when
citycode =3D =
FAT, the five day information for Fresno shows up .. and so
on. I was =
planning to use Spry tabs or whatever to show the data.
<!--
var dsCurrent =3D new Spry.Data.XMLDataSet("current.xml", =
"weather/current");
//-->
</script>
</head>
<body>=20
<div class=3D"MasterDetail">
<div spry:region=3D"dsCurrent"
class=3D"MasterContainer">
<div class=3D"MasterColumn" spry:repeat=3D"dsCurrent" =
spry:setrow=3D"dsCurrent" spry:hover=3D"MasterColumnHover" =
spry:select=3D"MasterColumnSelected">{location}</div>
</div>
<div spry:detailregion=3D"dsCurrent"
class=3D"DetailContainer">
<div class=3D"DetailColumn">{phrase}</div>
<div class=3D"DetailColumn">{temp}</div>
<div class=3D"DetailColumn">{temp/@units}</div>
<div class=3D"DetailColumn">{aptemp}</div>
<div class=3D"DetailColumn">{aptemp/@unit}</div>
<div class=3D"DetailColumn">{wndchl}</div>
<div class=3D"DetailColumn">{wndchl/@unit}</div>
<div class=3D"DetailColumn">{rhumid}</div>
<div class=3D"DetailColumn">{rhumid/@unit}</div>
<div class=3D"DetailColumn">{wind_dir}</div>
<div class=3D"DetailColumn">{windspeed}</div>
<div
class=3D"DetailColumn">{windspeed/@unit}</div>
<div class=3D"DetailColumn">{pres}</div>
<div class=3D"DetailColumn">{pres/@unit}</div>
<div class=3D"DetailColumn">{vis}</div>
<div class=3D"DetailColumn">{vis/@unit}</div>
<div class=3D"DetailColumn">{icon}</div>
</div>
Arnout gave me some suggestions .. but so far, I haven't
gotten either =
of them to work. Also I am trying to get some ideas from spry
Samples =
from the Spry home page/samples area, but again .. not yet.
Thanks,
Nancy
"kinblas" <[email protected]> wrote in
message =
news:[email protected]...
>I don't think you need to combine them just so they can
render in a =
tabbed=20
> widget. We're still missing a couple of key pieces of
information. =
What does=20
> the data that is used in the master region look like?
Are what you =
refer to as=20
> current.xml and forecast.xml really static files? Or are
they =
dynamically=20
> generated by a server side script (php/cf/etc)? There is
one current =
and=20
> forecast xml per city right?
>=20
> I ask these questions because you may be able to simply
set up a =
master detail=20
> relationship between 3 data sets and just use those
within a region(s) =
that=20
> build up the tab widget. Assuming you were getting the
list of cities =
from a=20
> 3rd source, you could set up something like this:
>=20
>=20
> var dsCities =3D new Spry.Data.XMLDataSet("cities.xml",
=
"/cities/city");
> var dsCurrent =3D new=20
>
Spry.Data.XMLDataSet("current.php?location=3D{dsCities::name}",=20
> "/weather/current");
> var dsForecast =3D new=20
>
Spry.Data.XMLDataSet("forecast.php?citycode=3D{dsCities::name}",=20
> "/weather/forecast/day");
>=20
>=20
> ...
>=20
>=20
> <div id=3D"TabbedPanels1" class=3D"TabbedPanels">
> <ul class=3D"TabbedPanelsTabGroup">
>
Current</li>
>
Forecast</li>
>
> <div class=3D"TabbedPanelsContentGroup">
> <div class=3D"TabbedPanelsContent"
spry:region=3D"dsCurrent">
> {temp}{temp/@unit}
> </div>
> <div class=3D"TabbedPanelsContent"
spry:region=3D"dsForecast">
>
> <li spry:repeat=3D"dsForecast">{name}<br
/>High: =
{high}{high/@unit}<br=20
> />Low: {low}{low/@unit}</li>
>
> </div>
> </div>
> </div>
>=20
>=20
>=20
> --=3D=3D Kin =3D=3D--
> -
How to parse XML document with default namespace with JDOM XPath
Hi All,
I am having difficulty parsing using Saxon and TagSoup parser on a namespace html document. The relevant content of this document are as follows:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div id="container">
<div id="content">
<table class="sresults">
<tr>
<td>
<a href="http://www.abc.com/areas" title="Hollywood, CA">hollywood</a>
</td>
<td>
<a href="http://www.abc.com/areas" title="San Jose, CA">san jose</a>
</td>
<td>
<a href="http://www.abc.com/areas" title="San Francisco, CA">san francisco</a>
</td>
<td>
<a href="http://www.abc.com/areas" title="San Diego, CA">San diego</a>
</td>
</tr>
</body>
</html>
Below is the relevant code snippets illustrates how I have attempted to retrieve the contents (value of <a>):
import java.util.*;
import org.jdom.*;
import org.jdom.xpath.*;
import org.saxpath.*;
import org.ccil.cowan.tagsoup.Parser;
( 1 ) frInHtml = new FileReader("C:\\Tmp\\ABC.html");
( 2 ) brInHtml = new BufferedReader(frInHtml);
( 3 ) // SAXBuilder saxBuilder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
( 4 ) SAXBuilder saxBuilder = new SAXBuilder("org.ccil.cowan.tagsoup.Parser");
( 5 ) org.jdom.Document jdomDocument = saxbuilder.build(brInHtml);
( 6 ) XPath xpath = XPath.newInstance("/ns:html/ns:body/ns:div[@id='container']/ns:div[@id='content']/ns:table[@class='sresults']/ns:tr/ns:td/ns:a");
( 7 ) xpath.addNamespace("ns", "http://www.w3.org/1999/xhtml");
( 8 ) java.util.List list = (java.util.List) (xpath.selectNodes(jdomDocument));
( 9 ) Iterator iterator = list.iterator();
( 10 ) while (iterator.hasNext())
( 11 ) {
( 12 ) Object object = iterator.next();
( 13 ) // if (object instanceof Element)
( 14 ) // System.out.println(((Element)object).getTextNormalize());
( 15 ) if (object instanceof Content)
( 16 ) System.out.println(((Content)object).getValue());
.This program would work on the same document without the default namespace, hence, it would not be necessary to include ns prefix along in the XPath statements (line 6-7) either. Moreover, I was using org.apache.xerces.parsers.SAXParser to have successfully retrieve content of <a> from the same document without default namespace in the past.
I would like to achieve the following objectives if possible:
( i ) Exclude DTD and namespace in order to simplifying the parsing process. How this could be done?
( ii ) If this is not possible, how to include it in XPath statements (line 6-7) so that the value of <a> is picked up correctly?
( iii ) Would changing from org.apache.xerces.parsers.SAXParser to org.ccil.cowan.tagsoup.Parser make any difference as far as using XPath is concerned?
( iv ) Failing to exlude DTD, how to change the lookup of a PUBLIC DTD to a local SYSTEM one and include a local DTD for reference?
I am running JDK 1.6.0_06, Netbeans 6.1, JDOM 1.1, Saxon6-5-5, Tagsoup 1.2 on Windows XP platform.
Any assistance would be appreciated.
Thanks in advance,
JackHere's an example of using a custom EntityResolver with the standard DocumentBuilder provided by the JDK. The code may or may not be similar for the parsers that you're using.
import java.io.IOException;
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public class ParseExamples
private final static String COMMON_XML
= "<music>"
+ "<artist name=\"Anderson, Laurie\">"
+ "<album>Big Science</album>"
+ "<album>Strange Angels</album>"
+ "</artist>"
+ "<artist name=\"Fine Young Cannibals\">"
+ "<album>The Raw & The Cooked</album>"
+ "</artist>"
+ "</music>";
private final static String COMMON_DTD
= "<!ELEMENT music (artist*)>"
+ "<!ELEMENT artist (album+)>"
+ "<!ELEMENT album (#PCDATA)>"
+ "<!ATTLIST artist name CDATA #REQUIRED>";
public static void main(String[] argv)
throws Exception
// this version uses just a SYSTEM identifier - note that it gets turned
// into a file: URL
String xml = "<!DOCTYPE music SYSTEM \"bar\">"
+ COMMON_XML;
// this version uses both PUBLIC and SYSTEM identifiers; the SYSTEM ID
// gets munged, the PUBLIC ID doesn't
// String xml = "<!DOCTYPE music PUBLIC \"foo\" \"bar\">"
// + COMMON_XML;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
DocumentBuilder db = dbf.newDocumentBuilder();
db.setEntityResolver(new EntityResolver()
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, IOException
System.out.println("publicId = " + publicId);
System.out.println("systemId = " + systemId);
return new InputSource(new StringReader(COMMON_DTD));
Document dom = db.parse(new InputSource(new StringReader(xml)));
System.out.println("root element name = " + dom.getDocumentElement().getNodeName());
}
Maybe you are looking for
-
Can I rollover an image to "remove" it to have clickable links show up once at hidden state?
I have a design wherein I want certain elements to change states on rollover. With this action, there would be a line of text with each one clickable to a different link. Right now I cannot find a good way to have one image "hide" on rollover, reveal
-
Something going on with Azure Website and Cloud Service?
Starting this morning, my website (WordPress) could not even load with Shared Plan. When I switch it to Basic plan it is running extremely slow (25s to load a page). This is a very low traffic site (100 page views/day). Even when there is only 1 conn
-
Firefox is installed on a MacPookPro running Snow Leopard
-
Anybody know how to contact a HP agent or customer service?
{Content Removed in Subject} Anybody know how to contact an HP customer support person?
-
I have CC 2014 but it says my trial has run out?
I have a copy of Adobe CC 2014. I am logged in correctly but it still says my trial has run out?