Patrick Luebbecke | 1 Oct 2008 12:15
Picon
Favicon

Reading out an attribute


lo all

i'd like to find the id attribute in the /application/module/ path. the
command i'm using to get that attribute is:

<copy path="/application/module/ <at> id" attrvalue="true" property="id_value"/>

but when i echo the property it just gives me the property name $
{id_value} , which means that it has not been read out of my xml structure.

in several cases i have to put a : in front of my path, for reading out
the /application/display-name/text() i have to use

<copy path="/:application/:display-name/text()" property="dn_value"/>

to make it work. but i have read a lot of xpath tutorials but i did not
found a lesson where i have to put colon in front of every node.
so how do i read out this id as mentioned above ? it worked for me 2 weeks
ago but after trying it again today i only get an empty property.

Thats my xml file:

<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_ID" version="1.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
      <display-name>EARFILE</display-name>
(Continue reading)

Lukacs, Gabriel | 1 Oct 2008 12:42
Picon

Re: Reading out an attribute


Hello,
please check the following link:
http://today.java.net/pub/a/today/2006/11/01/xml-manipulation-using-xmlt
ask.html (section Paths and Namespaces) 

With kind regards, Gabriel.

-----Original Message-----
From: Patrick Luebbecke [mailto:PATLUE@...] 
Sent: Wednesday, October 01, 2008 12:16 PM
To: Xmltask-users@...
Subject: [Xmltask-users] Reading out an attribute

lo all

i'd like to find the id attribute in the /application/module/ path. the
command i'm using to get that attribute is:

<copy path="/application/module/ <at> id" attrvalue="true"
property="id_value"/>

but when i echo the property it just gives me the property name $
{id_value} , which means that it has not been read out of my xml
structure.

in several cases i have to put a : in front of my path, for reading out
the /application/display-name/text() i have to use

<copy path="/:application/:display-name/text()" property="dn_value"/>
(Continue reading)

Patrick Luebbecke | 1 Oct 2008 14:13
Picon
Favicon

Fw: Reading out an attribute


Hi,

i cant just remove lines out of my xml file. this code is shown all in one
line in my file. i dont know why it is splitted by a line break in the
mailinglist.

with using this code:

<target name="AenderungApplicationXML" depends="warEntpacken"
description="Anpassungen in application.xml">
                  <xmltask source="${AppXML}"  >
                        <copy path="/:application/:display-name/text()"
property="dn_value"/>
                        <copy path="/:application/:module/ <at> id"
attrvalue="true" property="id_value"/>
                        <copy
path="/:application/:module/:web/:context-root/text()"
property="cr_value"/>
                  </xmltask>

i get the display-name element (EARFILE), i get the context-root
(ABCPortlets) but i DONT get the attribute 'id'. what would a proper Path
look like to read out the id attribute in /application/module/ <at> id ?

Regards

                                                                           
             Jackie James                                                  
             <Jackie_James <at> inf                                             
(Continue reading)

Lukacs, Gabriel | 1 Oct 2008 15:02
Picon

Re: Fw: Reading out an attribute

The XPath  seems to be ok, I have tried your code with your xml and it
works properly:

Buildfile: test.xml

AenderungApplicationXML:
     [echo] ID: WebModule_1213257640343
     [echo] DN: EARFILE
     [echo] CR: ABCPortlets

BUILD SUCCESSFUL
Total time: 0 seconds

I am using XmlTask 1.15.1 ...

Used code:
<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="AenderungApplicationXML" >
      <taskdef name="xmltask"
classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>

	<target name="AenderungApplicationXML" description="Anpassungen
in application.xml">
                  <xmltask source="application.xml"  >
                        <copy path="/:application/:display-name/text()"
property="dn_value"/>
                        <copy path="/:application/:module/ <at> id"
attrvalue="true" property="id_value"/>
                        <copy
path="/:application/:module/:web/:context-root/text()"
(Continue reading)

Brian Agnew | 1 Oct 2008 21:54
Favicon
Gravatar

[Fwd: Re: Reading out an attribute]

(forwarded due to mail problems)

-- 
Brian Agnew                  http://www.oopsconsultancy.com
OOPS Consultancy Ltd         brian  <at>  oopsconsultancy.com
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012

From: Agnew, Brian <Brian.Agnew@...>
Subject: Re: [Xmltask-users] Reading out an attribute
Date: 2008-10-01 10:29:41 GMT

A very quick test with your XML and the following:
 
<target name="abc">
<xmltask source="input.xml">
 <copy path="/:application/:module/ <at> id" attrvalue="true" property="dn_value"/> 
 
</xmltask>
<echo>${dn_value}</echo>
</target>
 
gives me WebModule_1213257640343
 
which appears to be correct. In the XPath examples (Continue reading)

Karr, David | 2 Oct 2008 00:12

Re: [Fwd: Re: Reading out an attribute]

Just to clarify one point of this, in an xpath test app that I wrote, if
I run a query like this on a similar file, if I don't add a mapping for
the "empty" prefix to the appropriate namespace, a query using the blank
prefix fails with "Prefix must resolve to a namespace".  It only works
when I add the mapping from the "" prefix to the namespace.

> -----Original Message-----
> From: Brian Agnew [mailto:brian@...] 
> Sent: Wednesday, October 01, 2008 12:55 PM
> To: 'xmltask-users@...'
> Subject: [Xmltask-users] [Fwd: Re: Reading out an attribute]
> 
> (forwarded due to mail problems)
> [forwarded message manually inserted here]
> A very quick test with your XML and the following:
>  
> <target name="abc">
> <xmltask source="input.xml">
>  <copy path="/:application/:module/ <at> id" attrvalue="true"
property="dn_value"/> 
>  
> </xmltask>
> <echo>${dn_value}</echo>
> </target>
>  
> gives me WebModule_1213257640343
>  
> which appears to be correct. In the XPath examples you're looking at,
the chances are they don't involve namespaces. If your example contains
namespaces (e.g. in the below) then you have to qualify your XML
(Continue reading)

Patrick Luebbecke | 7 Oct 2008 12:02
Picon
Favicon

Re: Reading out an attribute

Another day, another issue ;)

my script works so far but i had to split it into 2 scripts, each of it
processing 1 file. both do the following jobs:

1. unpack a file
2. read out node-attributes and element-names and store them in properties
3. replace the nodes with a Prefix and the specific property (like
Validation_${propertyName} )
4. zip the file

i'm doing this for 2 files so i had to split the code into 2 files
(actually split isn't the right word since the code is nearly identical).
the 1st buildscript processes file 1, the 2nd script file 2 since it's
impossible for me to overwrite the properties with the values read out in
the 2nd file (although the node scructure is quiet the same). is there any
way to solve this problem with only ONE build script?

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Lukacs, Gabriel | 7 Oct 2008 12:26
Picon

Re: Reading out an attribute

you can use the var task of the antcontrib external library
http://ant-contrib.sourceforge.net/tasks/tasks/index.html 

-----Original Message-----
From: Patrick Luebbecke [mailto:PATLUE@...] 
Sent: Tuesday, October 07, 2008 12:02 PM
To: Xmltask-users@...
Subject: Re: [Xmltask-users] Reading out an attribute

Another day, another issue ;)

my script works so far but i had to split it into 2 scripts, each of it
processing 1 file. both do the following jobs:

1. unpack a file
2. read out node-attributes and element-names and store them in
properties
3. replace the nodes with a Prefix and the specific property (like
Validation_${propertyName} )
4. zip the file

i'm doing this for 2 files so i had to split the code into 2 files
(actually split isn't the right word since the code is nearly
identical).
the 1st buildscript processes file 1, the 2nd script file 2 since it's
impossible for me to overwrite the properties with the values read out
in
the 2nd file (although the node scructure is quiet the same). is there
any
way to solve this problem with only ONE build script?
(Continue reading)

Patrick Luebbecke | 7 Oct 2008 12:46
Picon
Favicon

Re: Reading out an attribute

Thanks dude, you're very fast ;) I never took notice of that task before.

Regards

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Lukacs, Gabriel | 7 Oct 2008 12:32
Picon

Re: Reading out an attribute

I have meant this one:
http://ant-contrib.sourceforge.net/tasks/tasks/variable_task.html 

-----Original Message-----
From: Lukacs, Gabriel 
Sent: Tuesday, October 07, 2008 12:27 PM
To: Patrick Luebbecke; Xmltask-users@...
Subject: Re: [Xmltask-users] Reading out an attribute

you can use the var task of the antcontrib external library
http://ant-contrib.sourceforge.net/tasks/tasks/index.html 

-----Original Message-----
From: Patrick Luebbecke [mailto:PATLUE@...] 
Sent: Tuesday, October 07, 2008 12:02 PM
To: Xmltask-users@...
Subject: Re: [Xmltask-users] Reading out an attribute

Another day, another issue ;)

my script works so far but i had to split it into 2 scripts, each of it
processing 1 file. both do the following jobs:

1. unpack a file
2. read out node-attributes and element-names and store them in
properties
3. replace the nodes with a Prefix and the specific property (like
Validation_${propertyName} )
4. zip the file

(Continue reading)


Gmane