RE: dumping XML document

2007-01-04 Thread Kralidis,Tom [Burlington]
 

 -Original Message-
 From: Kris Schneider [mailto:[EMAIL PROTECTED] 
 Sent: 03 January, 2007 10:40 AM
 To: Tag Libraries Users List
 Subject: Re: dumping XML document
 
 Kralidis,Tom [Burlington] wrote:
  Hi,
  
  Using tomcat 6.0.0, I am using the following fragment to fetch a 
  remote XML document:
  
  c:catch var=caught
   c:import url=${param.url} varReader=xmlSource
x:parse var=doc xml=${xmlSource} scope=page /  
 /c:import 
  /c:catch
  
  Using x:out select=$doc/./ allows for fetching of values of 
  elements / attributes as expected.  I have encountered a situation 
  where I would like to fetch and store the entire document 
 in a database.
  
  Trying x:out select$doc/ outputs the entire XML 
 document without 
  the element names, etc. (i.e. only the content within the 
 elements / 
  attributes).
  
  Any idea on what's the best way to achieve this?
 
 Some questions:
 Do you always want to store the entire doc or only under 
 certain conditions?
 

The page is built to respond to a certain operation, so always.

 How do you want to store the doc? For example, as a CLOB or 
 something else?

Quite simply as a text string (i.e. PostgreSQL text type).



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



dumping XML document

2007-01-02 Thread Kralidis,Tom [Burlington]

Hi,

Using tomcat 6.0.0, I am using the following fragment to fetch a remote
XML document:

c:catch var=caught
 c:import url=${param.url} varReader=xmlSource
  x:parse var=doc xml=${xmlSource} scope=page /
 /c:import
/c:catch

Using x:out select=$doc/./ allows for fetching of values of
elements / attributes as expected.  I have encountered a situation where
I would like to fetch and store the entire document in a database.

Trying x:out select$doc/ outputs the entire XML document without the
element names, etc. (i.e. only the content within the elements /
attributes).

Any idea on what's the best way to achieve this?

Thanks

..Tom


=
Tom Kralidis
Senior Systems Scientist
Environment Canada
Tel: +01-905-336-4409
http://www.ec.gc.ca/
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



JSP/JSTL set var problem

2005-11-04 Thread Kralidis,Tom [Burlington]

Hi,

I have an XML config file (attached) which I'd like to set a bunch of
JSP variables.

The xml config file is something like:

config
 property name=city value=Toronto/
 property name=prov value=Ontario/
...
/config

Basically, I'd like to set variables with names in property/@name, and
value of property/@value.  So the above example would allow me to use
c:out value=${city}/ type of thing.

Here's my code snippet:

c:import url=./config.xml varReader=xmlSource
 x:parse var=doc xml=${xmlSource} scope=page /
/c:import

x:forEach select=$doc/*[local-name()='config' and
namespace-uri()='http://devgeo.cciw.ca/owscat/etc/properties']/*[local-n
ame()='property' and
namespace-uri()='http://devgeo.cciw.ca/owscat/etc/properties']
var=loc
 c:set var=@name scope=page value=@value/
/x:forEach

Any idea on how to make this work?  I get no errors on output but the
values are not being set.

Thanks

..Tom

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Accessing URL with authentication

2005-07-11 Thread Kralidis,Tom [Burlington]

Hi,

I have a JSP which attempts to fetch a URL and process the XML.  The URL
I'm accessing is password protected with basic HTTP authentication.

c:set scope=page var=requestURL
value=http://user:[EMAIL PROTECTED]/process?lang=en-CAservice_type=${type}url
=${url}/
h4Inserting ${url} (${type})/h4
c:catch var=caught
 c:import url=${requestURL} varReader=xmlSource
  x:parse var=doc xml=${xmlSource} scope=page /
 /c:import
/c:catch

c:if test=${not empty caught}
 h4${caught.rootCause}/h4
 h4${caught.message}/h4
/c:if

When running this, the error message I get back is:

java.io.IOException: Server returned HTTP response code: 401 for URL:
theurl
Problem accessing the absolute URL theurl

However if I run the URL in the browser it authenticates with no
problems.

Is there a more proper, elegant way to do this?

..Tom

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



join and arrays

2005-05-26 Thread Kralidis,Tom [Burlington]

Hi,

I have a JSP which parses an XML document and inserts records into a DB.

For multiple XML elements, I do the following:

sql:transaction dataSource=${ds_devgeodb}
 sql:update
  insert into service_endpoints (keywords) values
 ('x:forEach
select=$doc/WMT_MS_Capabilities/Service/KeywordList/Keyword
var=kwx:out select=text()/,/x:forEach')
 /sql:update
/sql:transaction

Which works okay, except that the values in the DB end up as:

keyword1,keyword2,keyword3,

..whereas I would prefer

keyword1,keyword2,keyword3

(i.e. without the trailing comma)

I checked the fn:join() function, which looks like it would do the
trick, but how does one set an array in JSTL?

Any advice would be appreciated.

Thanks

..Tom

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



XML processing question

2005-03-31 Thread Kralidis,Tom [Burlington]

Hi,

I'm having an issue working with an XML response from a web service.

Environment:

tomcat 5.0.25
Fedora Core 2

URL of XML response:
http://devgeo.cciw.ca/cgi-bin/mapserv/eccat?version=1.0.0service=WFSre
quest=GetCapabilities

I can't seem to work with the response or identify specific XPath's
which I know exist.  Below is the code I am testing with:

[EMAIL PROTECTED] contentType=text/html%
%@ taglib prefix=c  uri=http://java.sun.com/jsp/jstl/core; %
%@ taglib prefix=x  uri=http://java.sun.com/jsp/jstl/xml; %

html
 head
  titletest/title
 /head
 body
  c:set var=requestURL scope=page
value=http://devgeo.cciw.ca/cgi-bin/mapserv/eccat?version=1.0.
0service=WFSrequest=GetCapabilities/
  c:import url=${requestURL} varReader=xmlSource
   x:parse var=doc xml=${xmlSource} scope=page /
  /c:import

  pVersion is: x:out select=$doc/WFS_Capabilities/@version//p
 /body
/html

...any suggestions would be valued.

Thanks

..Tom

=
Tom Kralidis
Senior Systems Scientist
Environment Canada
Tel: +01-905-336-4409
http://www.ec.gc.ca/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



connecting to PostgreSQL

2005-03-24 Thread Kralidis,Tom [Burlington]

Hi,

I have a PostgreSQL instance running to which I'd like to connect to
with.

Can someone kindly point to documentation, examples, etc. on how to do
this?  I've found much docs for ODBC connections.

Thanks alot

..Tom

=
Tom Kralidis
Senior Systems Scientist
Environment Canada
Tel: +01-905-336-4409
http://www.ec.gc.ca/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



setting values from current date

2005-01-23 Thread Kralidis,Tom [Burlington]

Hi,

I'm writing an HTML page (from JSP/JSTL) which provides two select boxes
for day/month/year for a temporal query.

What I would like to do is set the 2nd select box with today's
day/month/year values.  I am able to get today's date from:

jsp:useBean id=now class=java.util.Date /
Date: fmt:formatDate value=${now} dateStyle=full /

How can I isolate the day/month/year values into seperate variables, so
that I can use them when looping over to create my select box
(basically, when the select box value equals today's day/month/year, add
SELECTED.

Cheers

..Tom

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Comparing XML value to variable

2005-01-23 Thread Kralidis,Tom [Burlington]

Hi,

I'm populating an HTML select box with contents from an XML document.
Here's a snippet of the XML doc:

months
 month name=January value=01/
 month name=February value=02/
...
/months

My JSP page parses the XML document and prints out the select box as per
below.  The problem is that the x:when statment doesn't do what I want
it to (i.e. when the month value from the XML doc matches the
monthcurrent value, the select option gets the selected value added.

NB: monthcurrent is picked up as the current month number i.e. 01.  

select name=monthend
 x:forEach select=$doc/calendar/months/month var=m
   x:choose
x:when select=@value = monthcurrent
 c:set var=selected value= selected/
/x:when
x:otherwise
 c:set var=selected value=/
/x:otherwise
   /x:choose
   option value=x:out select=@value/${selected}x:out
select=@name//option
 /x:forEach
/select

..the output I'm looking for is:

select name=monthend
 option value=01 selectedJanuary/option
 option value=02February/option
...
/select

Any idea on what I'm doing wrong?

Thanks

..Tom

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



splitting a variable into array

2004-09-07 Thread Kralidis,Tom [Burlington]

Hi,

When working with tomcat 5.0.27, I am trying to parse an XML document
and split the value of an XPath statement into an array for further
usage throughout the document:

c:import url=${requestURL} varReader=xmlSource
x:parse var=doc xml=${xmlSource} scope=application /
/c:import

c:set var=xy scope=session
x:out
select=$doc/PostalCodeLookup/PostalCodeResultSet/PostalCode/*/*/*/
/c:set

% // this works %

c:out value=${xy}/

c:set var=coords scope=session value=${fn:split($xy,',')}/

% // this doesn't work %

c:out value=${coords[0]}/

Any idea what I may be missing here?

Thanks

..Tom

=
Tom Kralidis
Systems Scientist
Environment Canada
Tel: +01-905-336-4409
http://www.ec.gc.ca/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Issue using x:transform

2004-02-27 Thread Kralidis,Tom [Burlington]

Hi,

Using jakarta-tomcat-5.0.18, I have a simple JSP:

[EMAIL PROTECTED] contentType=text/html%
%@ taglib uri=http://java.sun.com/jstl/xml; prefix=x %
%@ taglib uri=http://java.sun.com/jstl/core; prefix=c %
html
head
titletest/title
/head
body
form name=myform method=post action=none
c:import
url=http://cgdi-dev.geoconnections.org/prototypes/mapbuilder/demo/locations
/Global.xml var=xmlDoc /
c:import
url=http://cgdi-dev.geoconnections.org/prototypes/mapbuilder/lib/widget/loc
ations/Locations2Select.xsl var=xsltDoc /
x:transform xml=${xmlDoc} xslt=${xsltDoc} /
/form
/body
/html

...however, when I run this, I receive error:

org.apache.jasper.JasperException: /tk_test/xsl.jsp(14,0) According to TLD
or attribute directive in tag file, attribute xml does not accept any
expressions
more error messages

The wierd thing is I've seen a similar example on the onjava.com site at:

http://www.onjava.com/pub/a/onjava/excerpt/jsvltjspckbk_chap01/index.html?pa
ge=3

Any idea what may be incorrect in the code above?

Thanks

..Tom

=
Tom Kralidis
Systems Scientist
Environment Canada
Tel: +01-905-336-4409
http://www.ec.gc.ca/cise/


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Issue using x:transform

2004-02-27 Thread Kralidis,Tom [Burlington]

This worked, thanks alot.  I tried putting these into $CATALINA_HOME/common,
but it didn't work.  Basically, I wouldn't want to keep copying these as
webapps pile up.

Thanks

..Tom

 -Original Message-
 From: Kris Schneider [mailto:[EMAIL PROTECTED] 
 Sent: Friday, February 27, 2004 10:52 AM
 To: Tag Libraries Users List
 Subject: Re: Issue using x:transform
 
 
 Make sure you're using JSTL 1.1 with TC 5. The taglib 
 directives should look
 like:
 
 %@ taglib uri=http://java.sun.com/jsp/jstl/xml; prefix=x 
 % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %
 
 Quoting Kralidis,Tom [Burlington] [EMAIL PROTECTED]:
 
  
  Hi,
  
  Using jakarta-tomcat-5.0.18, I have a simple JSP:
  
  [EMAIL PROTECTED] contentType=text/html%
  %@ taglib uri=http://java.sun.com/jstl/xml; prefix=x % 
 %@ taglib 
  uri=http://java.sun.com/jstl/core; prefix=c % html
  head
  titletest/title
  /head
  body
  form name=myform method=post action=none
  c:import
  
 url=http://cgdi-dev.geoconnections.org/prototypes/mapbuilder/
 demo/locations
  /Global.xml var=xmlDoc /
  c:import
  
 url=http://cgdi-dev.geoconnections.org/prototypes/mapbuilder/
 lib/widget/loc
  ations/Locations2Select.xsl var=xsltDoc /
  x:transform xml=${xmlDoc} xslt=${xsltDoc} /
  /form
  /body
  /html
  
  ...however, when I run this, I receive error:
  
  org.apache.jasper.JasperException: /tk_test/xsl.jsp(14,0) 
 According to 
  TLD or attribute directive in tag file, attribute xml does 
 not accept 
  any expressions more error messages
  
  The wierd thing is I've seen a similar example on the 
 onjava.com site 
  at:
  
  
 http://www.onjava.com/pub/a/onjava/excerpt/jsv ltjspckbk_chap01/index.h
  tml?pa
  ge=3
  
  Any idea what may be incorrect in the code above?
  
  Thanks
  
  ..Tom
  
  =
  Tom Kralidis
  Systems Scientist
  Environment Canada
  Tel: +01-905-336-4409
  http://www.ec.gc.ca/cise/
 
 -- 
 Kris Schneider mailto:[EMAIL PROTECTED]
 D.O.Tech   http://www.dotech.com/
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



XML processing with target namespace documents

2004-01-08 Thread Kralidis,Tom [Burlington]

Hi,

We've been using JSTL 1.0, with success, to process some web services within
our software.

When processing an XML document which has a target namespace, i.e.:

MyOutput version=1.0.0 xmlns=http://localhost/myoutput;
xmlns:gml=http://www.opengis.net/gml;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://localhost/myoutput
http://localhost/watershed.xsd;


With the following code snippet:

...
  c:import url=${requestURL} varReader=xmlSource
   x:parse var=doc xml=${xmlSource} scope=application /
  /c:import
  x:out select=$doc/MyOutput/@version/



No value is returned on x:out.  If the XML document has no target namespace,
all works as expected.

Any suggestions here?  We are starting to deal with alot of XML which is
designed in this fashion.  We also run into the same issue for XML document
with elements which have namespaces, i.e. gml:nametom/gml:name.

Thanks much

..Tom

=
Tom Kralidis
Systems Scientist
Environment Canada
Tel: +01-905-336-4409
http://www.ec.gc.ca/cise/
= 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]