XPath question

I am trying to populate an accordion using an XML document as
follows:
<?xml version="1.0" encoding="iso-8859-1"?>
<images xmlns="
http://www.g-raff.com/images">
<groups>
<group groupname="Martyn's favourites">
<image>
<filename>atomic-kitten-1.jpg</filename>
<title>Atomic Kitten</title>
<date>23.8.2004</date>
<place>London</place>
</image>
<image>... </image>
etc.
</group>
<group groupname="Painting with light">
<image>
<filename>a.jpg</filename>
<title>a</title>
<date>15.4.2003</date>
<place>peckham rye</place>
</image>
etc.
</group>
<group groupname="Musicians">
<image>
<filename>atomic-kitten-1.jpg</filename>
<title>Atomic Kitten</title>
<date>23.8.2004</date>
<place>London</place>
<target>people1</target>
</image>
etc.
</group>
</groups>
</images>
Now - in creating the data sets, I want to generate a set of
thumbnails for each "group" - I have the following code:
var dsGroups = new Spry.Data.XMLDataSet("images.xml",
"/images/groups/group");
var dsImages = new Spry.Data.XMLDataSet("images.xml",
"/images/groups/group[@groupname =
'{dsGroups::@groupname}']/image")
I am then using the following to label the accordion and
populate the panels:
<div id="NavAcc" class="Accordion" spry:region="dsGroups
dsImages">
<div class="AccordionPanel" spry:repeat="dsGroups">
<div class="AccordionPanelLabel">
<h3>{dsGroups::@groupname}</h3>
</div>
<div class="AccordionPanelContent">
<div id="thumbs">
<div class="thumbnail" spry:repeat="dsImages">
<img class="thumb"
src="images/thumbnails/{dsImages::filename}"
alt="{dsImages::title}"
onclick="dsImages.setCurrentRow('{ds_RowID}');" width="92"
height="60" />
<p class="caption">{dsImages::title}</p>
</div>
</div>
</div>
</div>
</div>
Its not working - dsImages is failing. I know it must be to
do with the way I'm trying to filter by the attribute "groupname",
as I'm not sure whether the "@" is allowed in this context.
Can anyone point me at a fulfilling explanation of xPath
syntax so I can figure out how to achieve this?
Thanks yet again,
raff J

I encountered the same (or very similar) problem. In my case,
with a photo album xml where the layout is similar (see below) and
I need to pull the image folder url from the parent dataset and the
image urls from a series of <img> tags. I also could not
figure out a way to do this, and would very much appreciate an
example of how it is done.
what did not work was setting up the datasets as
var dsPhotos = new Spry.Data.XMLDataSet("sample.xml",
"gallery/album")
var dsImages = new Spry.Data.XMLDataSet("sample.xml",
"gallery/album[@pID = '{dsPhotos::pID}']/img")
Sample XML:
<?xml version="1.0" encoding="utf-8"?>
<!-- XML Generated by SlpIDeShowPro Director v1.0.2 -->
<gallery>
<album pID="8" title="Rose River" description="Rose River
Hike" lgPath="
http://www.zakar.com/ssp_director/albums/RoseRiver/lg/"
tnPath="
http://www.zakar.com/ssp_director/albums/RoseRiver/tn/"
tn="
http://www.zakar.com/ssp_director/albums/RoseRiver/tn/P5030196.jpg">
<img src="P5030211.jpg" title="" caption="P5030211.jpg"
link="
http://" />
<img src="P5030196.jpg" title="" caption="P5030196.jpg"
link="
http://" />
<img src="P5030197.jpg" title="" caption="P5030197.jpg"
link="
http://" />
</album>
<album pID="9" title="Stony Man / Little Stony Man
Cliffs" description="Great views " lgPath="
http://www.zakar.com/ssp_director/albums/Stonyman/lg/"
tnPath="
http://www.zakar.com/ssp_director/albums/Stonyman/tn/"
tn="
http://www.zakar.com/ssp_director/albums/Stonyman/tn/P5020182.jpg">
<img src="P5020195.jpg" title="" caption="P5020195.jpg"
link="
http://" />
<img src="P5020178.jpg" title="" caption="P5020178.jpg"
link="
http://" />
<img src="P5020179.jpg" title="" caption="P5020179.jpg"
link="
http://" />
</album>
</gallery>

Similar Messages

  • XML/XPath question--how to select a range of elements with XPath?

    Hi there,
    I have an XML DOM in memory. I need to do hold it and issue only parts of it to my client app in "pages". Each page would be a self-contained XML doc, but would be a subset of the original doc. So for instance the first page is top-level elements 1-5. 2nd page would be 6-10 etc. Is this solution best solved with XPath? If not, what's the best way? If so, I have the following question:
    Is there a way to use XPath to select a range of nodes based on position within the document? I know I can do an XPath query that will return a single Node based on position. So for example if I wanted the first node in some XML Book Catalog I could do XPathAPI.selectSingleNode(doc, "/Catalog/Book[position()=1]"); I could wrap the previous call in a loop, replacing the numeric literal each time, but that seems horribly inefficient.
    Any ideas? Thanks much in advance!
    Toby Buckley

    Your question is about marking a range of cells. 99% of the code posted has nothing to do with this. If you want to create a simple table for test purposes then just do:
    JTable table = new JTable(10, 5);
    JScrollPane scrollPane = new JScrollPane( table );
    getContentPane().add( scrollPane );
    In three line of code you have a simple demo program.
    When I leave the mouse button again, these bunch/range of cells shall stay "marked". table.setCellSelectionEnabled( true );
    and I'd like to obtain, say, a vector of a vector containing just those data marked beforeUse the getSelectedRows() and getSelectedColumns() methods for this information. I would suggest you create a Point object to reflect the row/column position and then add the point to an ArrayList.

  • Problem with getNodeValue() - simple Java XPath question

    I am trying to extract the node values from a XML file:
    <root>
      <frame>
         <boxes>
           <box>
              <spec>22</spec>
              <spec>2222</spec>
           </box>
           <box>
              <spec id="BA" value="short"/>
              <spec id="BB" value="thin"/>
              <spec id="BC" value="black"/>
              <spec id="BD" value="full"/>
              <spec id="BE" value="7"/>
              <spec id="BF" value="deactive"/>
           </box>                
         </boxes>
         <circles>
           <circle id="CA" value="blue"/>
           <circle id="CB" value="green"/>
         </circles>
      </frame>
    </root>I use this code:
             XPathFactory factory = XPathFactory.newInstance();
             XPath xpath = factory.newXPath();
             XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec");            
             Object result = xPathExpression.evaluate(doc, XPathConstants.NODESET);
             NodeList nodes = (NodeList) result;
             for (int i = 0; i < nodes.getLength(); i++) {
                 System.out.println(nodes.item(i).getNodeValue());
             }But only:
    null
    null
    null
    null
    null
    null
    null
    null
    get printed. I would have assumed:
    22
    2222
    null
    null
    null
    null
    null
    null
    since the two first spec nodes contains the above numbers. Any ideas?

    change this:
    XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec");to this:
    XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec/text()");Need to xpath all the way down to the text of the node.
    You could use
    System.out.println(nodes.item(i).getTextContent());with your current xpath but if the spec node has children, these will also be included in the output.

  • XSLT Xpath question

    Hello all,
    I am kind of a newbie to the xpath sort of translation.
    I am curious on how to:
    Grab the last element with data from the input side of my xsl ?
    I appreciate any help on this.
    Jaden

    I guess I should explain what I am trying to accomplish :)
    I am trying to map an inbound 856 thru the xsl transformation.
    in the pack loop is the delivery detail id. under that are several item loops.
    My issue is that the Item Loop has the serial number where the Pack loop has the delivery detail. I need to copy the deliver detail id for each of the items for the output side of my transformation.
    I use the code /ns1:Transaction-856/ns1:Loop-HL/ns1:Segment-LIN/ns1:Element-234_1[last()]
    But i get only the first number in my output?
    Ty in advance
    Jaden

  • Spry XPath question

    This is a multi-part message in MIME format.
    ------=_NextPart_000_00F9_01C6872E.F574B670
    Content-Type: text/plain;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    I have an XML file which describes vacation listings. It is
    divided into =
    major locations (in the code below, U.S. and Mexico) which,
    in turn, =
    include property listings and details. I've gotten it to work
    in a basic =
    master-detail page, but only by ignoring the major locations.
    (In my =
    data set creation code, the XPath expression points to =
    "vacations/location/property"). What I'd really like is to do
    something =
    like this following:
    Region Location Property
    US Florida Vista Hills
    Vancouver Northern Palace
    Mexico Cancun Playa de Picante
    Would I need two data sets to pull this off?
    Best - Joe
    <?xml version=3D"1.0" encoding=3D"iso-8859-1"?>
    <vacations>
    <location>
    <place>U.S.</place>
    <property>
    <name>Vista Hills</name>
    <destination>Florida</destination>
    <contact>407-555-1234</contact>
    <description>The perfect family vacation resort, near
    all area =
    amusement parks.</description>
    <image>vista_hills.jpg</image>
    </property>
    <property>
    <name>Northern Palace</name>
    <destination>Vancouver</destination>
    <contact>407-555-5678</contact>
    <description>Enjoy great shopping and whale watching
    in the ultimate =
    stylish setting.</description>
    <image>northern_palace.jpg</image>
    </property>
    </location>
    <location>
    <place>Mexico</place>
    <property>
    <name>Playa de Picante</name>
    <destination>Cancun</destination>
    <contact>+52-998-555-1234</contact>
    <description>Fun in the sun to the max - don't miss
    the vacation of a =
    lifetime.</description>
    <image>picante.jpg</image>
    </property>
    </location>
    </vacations>
    ------=_NextPart_000_00F9_01C6872E.F574B670
    Content-Type: text/html;
    charset="iso-8859-1"
    Content-Transfer-Encoding: quoted-printable
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=3DContent-Type content=3D"text/html; =
    charset=3Diso-8859-1">
    <META content=3D"MSHTML 6.00.2900.2873"
    name=3DGENERATOR>
    <STYLE></STYLE>
    </HEAD>
    <BODY>
    <DIV><FONT face=3DArial size=3D2>I have an XML
    file which describes =
    vacation=20
    listings. It is divided into major locations (in the
    code below, =
    U.S. and=20
    Mexico) which, in turn, include property listings and
    details. I've =
    gotten it to=20
    work in a basic master-detail page, but only by ignoring the
    major =
    locations.=20
    (In my data set creation code, the XPath expression points to
    "<SPAN=20
    style=3D"FONT-SIZE: 10pt; COLOR: maroon; FONT-FAMILY: Arial;
    =
    mso-fareast-font-family: 'Times New Roman';
    mso-bidi-font-family: 'Times =
    New Roman'; mso-ansi-language: EN-US; mso-fareast-language:
    EN-US; =
    mso-bidi-language:
    AR-SA">vacations/location/property</SPAN>").=20
    What I'd really like is to do something like this =
    following:</FONT></DIV>
    <DIV><FONT face=3DArial
    size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial=20
    size=3D2><U>Region        Locatio=
    n       =20
    Property</U></FONT></DIV>
    <DIV><FONT face=3DArial=20
    size=3D2>US          &n=
    bsp;  =20
    Florida        
     Vista=20
    Hills</FONT></DIV>
    <DIV><FONT face=3DArial=20
    size=3D2>          &nbs=
    p;       =20
    Vancouver    Northern
    Palace</FONT></DIV>
    <DIV><FONT face=3DArial =
    size=3D2>Mexico       =20
    Cancun         Playa
    de=20
    Picante</FONT></DIV>
    <DIV><FONT face=3DArial
    size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2>Would I need two
    data sets to pull this =
    off?</FONT></DIV>
    <DIV><FONT face=3DArial
    size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2>Best -
    Joe</FONT></DIV>
    <DIV><FONT face=3DArial
    size=3D2></FONT> </DIV>
    <DIV><FONT face=3D"Courier New"
    size=3D2>&lt;?xml version=3D"1.0"=20
    encoding=3D"iso-8859-1"?&gt;<BR>&lt;vacations&gt;<BR>&lt;location&gt;<BR>=
     &lt;place&gt;U.S.&lt;/place&gt;<BR> &lt;property&gt;<BR> =
     &lt;name&gt;Vista=20
    Hills&lt;/name&gt;<BR>  &lt;destination&gt;Florida&lt;/destinat=
    ion&gt;<BR>  &lt;contact&gt;407-555-1234&lt;/contact&gt;<BR>&nb=
    sp; &lt;description&gt;The=20
    perfect family vacation resort, near all area amusement=20
    parks.&lt;/description&gt;<BR>  &lt;image&gt;vista_hills.jpg&lt=
    ;/image&gt;<BR> &lt;/property&gt;<BR> &lt;property&gt;<BR>&nbsp=
    ; &lt;name&gt;Northern=20
    Palace&lt;/name&gt;<BR>  &lt;destination&gt;Vancouver&lt;/desti=
    nation&gt;<BR>  &lt;contact&gt;407-555-5678&lt;/contact&gt;<BR>=
      &lt;description&gt;Enjoy=20
    great shopping and whale watching in the ultimate stylish=20
    setting.&lt;/description&gt;<BR>  &lt;image&gt;northern_palace.=
    jpg&lt;/image&gt;<BR> &lt;/property&gt;<BR>&lt;/location&gt;<BR>&lt;=
    location&gt;<BR> &lt;place&gt;Mexico&lt;/place&gt;<BR> &lt;prop=
    erty&gt;<BR>  &lt;name&gt;Playa=20
    de=20
    Picante&lt;/name&gt;<BR>  &lt;destination&gt;Cancun&lt;/destina=
    tion&gt;<BR>  &lt;contact&gt;+52-998-555-1234&lt;/contact&gt;<B=
    R>  &lt;description&gt;Fun=20
    in the sun to the max - don't miss the vacation of a=20
    lifetime.&lt;/description&gt;<BR>  &lt;image&gt;picante.jpg&lt;=
    /image&gt;<BR> &lt;/property&gt;<BR>&lt;/location&gt;<BR>&lt;/vacati=
    ons&gt;</FONT></DIV></BODY></HTML>
    ------=_NextPart_000_00F9_01C6872E.F574B670--

    Thanks, Kin -
    I figured out how to create the two data sets as you
    described, but was
    looking for the single list solution with nested repeating
    nodes.
    Looking forward to your solution!
    Best - Joe
    "kinblas" <[email protected]> wrote in
    message
    news:e62dkj$qun$[email protected]..
    > Hi Joe,
    >
    > If you are trying to display the info for "place",
    "name" and
    > "destination"
    > all in one table or list we can't handle that at the
    moment due to the way
    > we
    > flatten the XML into a data set. Repeating nodes
    underneath repeating
    > nodes get
    > discarded.
    >
    > We're working on a solution though.
    >
    > We can handle your XML structure with a Master/Detail
    pattern though.
    >
    > var dsPlaces = new XMLDataSet("location.xml",
    > "/vacations/location/place");
    > var dsProperties = new XMLDataSet("location.xml",
    > "/vacations/location[place =
    > '{dsPlaces::place}']/property");
    >
    > Using data sets like the above would assume that you'd
    have a place for
    > users
    > to click on a list of places and the detail area would
    display the
    > properties
    > for the currently selected place.
    >
    > --== Kin ==--
    >

  • Simple XPATH question

    Hi everybody,
    I'm trying to figure how to code my XPATH expression to get some information inside a XHTML page.
    If I use that XPATH:
    /tr/span/td[@id="COL"]/spanI get this:
    &lt;span id="check31"&gt;
      &lt;input value="31"/&gt;
    &lt;/span>
    &lt;span id="check32"&gt;
      &lt;input value="32"/&gt;
    &lt;/span&gt;
    &lt;span id="check33"&gt;
      &lt;input value="33"/&gt;
    &lt;/span&gt;In that result, I only want the second &lt;span&gt; tag. How do I code my XPATH ?
    I tried this:
    /tr/span/td[@id="COL"]/span[2]but it doesn't work.
    Currrently, as a work around, I code something like this:
       select extract(extract(V_XMLTYPE,
                              '/tr/span/td[@id="COL"]/span'), '/span[2]')
         from dual;Thank you for any help.

    change this:
    XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec");to this:
    XPathExpression xPathExpression = xpath.compile("/root/frame/boxes/box/spec/text()");Need to xpath all the way down to the text of the node.
    You could use
    System.out.println(nodes.item(i).getTextContent());with your current xpath but if the spec node has children, these will also be included in the output.

  • XPath question (select on tag string contents)

    Hi,
    I have the following XML file (a wikinews dump):
    <mediawiki>
      <page>
        <title>Image:Wiki.png</title>
        <id>1</id>
        <restrictions>move=sysop:edit=sysop</restrictions>
        <revision>
          <id>92375</id>
          <timestamp>2005-06-29T02:57:00Z</timestamp>
          <contributor>
            <username>NGerda</username>
            <id>2442</id>
          </contributor>
          <text xml:space="preserve">Wikinews logo.
    {{CopyrightByWikimedia}}</text>
        </revision>
      </page>
    </mediawiki>(with more <page> elements of course)
    I would like to only select those pages (titles and text) where the title does not contain 'category:' or 'Image:' or 'Template:' etc. or just does not contain ':' (I do not have all the pages, only most of them).
    What would be the right XPath expression?
    Any help is greatly appreciated!
    GrandiJoos
    Edited by: Grandi on Oct 6, 2007 7:05 AM
    Expanded topic title

    Something like:
    /mediawiki/page[not(contains(title, ':'))]

  • XPath Question related to xsi:type

    I have the response of a service callout that I need to process. The service callout response uses xsi:type to specify the type of the object being returned. I need to use the value of the xsi:type attribute to collect the xml elements.
    Here is the xpath that I am trying to use:
    $addAssetInfoResponse/ast:addAssetInfoResponse/ast:result/ast:asset\[local-name-from-QName(attribute::xsi:type)='Customer'\]
    (ast: is mapped to http://www.fatspaniel.com/ws/asset/)
    When I test this XPath with the following XML fragement as value of addAssetInfoResponse variable:
    <env:Body xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <ns2:addAssetInfoResponse xmlns:ns2="http://www.fatspaniel.com/ws/asset/" >
    <ns2:result>
    <ns2:status>SUCCESS</ns2:status>
    <ns2:asset xsi:type="ns4:Customer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="http://www.fatspaniel.com/ws/sysobj/" >
    <entityId>106934</entityId>
    <type>Customer</type>
    <name>AAI Customer - 200909081651</name>
    </ns2:asset>
    </ns2:result>
    </ns2:addAssetInfoResponse>
    </env:Body>
    I get the following error:
    Error executing the transformation: {err}XP0021: "ns4:Customer": can not cast to {http://www.w3.org/2001/XMLSchema}QName: error: Invalid QName value: Can't resolve prefix 'ns4'
    Have I made a mistake in the xpath ? Is there a better way for extracting assets elements of certain type ?
    Thank you.
    Rahul Phadnis
    Edited by: RahulPhadnis on Sep 15, 2009 10:57 AM

    John Spencer wrote:
    Unless I missed something in the 11g new features, the maximum line length in DBMS_OUTPUT.Put_Line is still 255 characters.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> set serveroutput on
    SQL> exec dbms_output.put_line(lpad('X',512,'X'));
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    PL/SQL procedure successfully completed.
    SQL> SY.

  • JSTL XPATH question

    I am using the XML taglib from JSTL 1.1 (SDK 1.5.0_03, Tomcat 5.5.9) in a JSP page. I am unable to get a node-set count; it always returns 0. I can loop through the docment and retrieve values, but no node functions (count( ), position( ), etc.).
    Example:
    <x:out select="count($doc/INVOICE_SETUPS/INVOICE_SETUP)" />
    Does anyone have an idea as to what this could be? Any information would be greatly appreciated.
    William

    William,
    I have had the same problem and it is indeed painful. Try this as a start:
         <x:out select="name($doc)" />      If you have the same problem I've had then the name of this node list will not be what you expected.
    I think I have finally found the solution, as follows. The confusion I had was over the contents of the rowset resulting from use of x:parse. Firstly, these are my taglib prefixes:
    <%@ taglib prefix="c" uri="/jstl/core" %>
    <%@ taglib prefix="x" uri="/jstl/xml" %>
    <%@ taglib prefix="sql" uri="/oracle/sql" %>      I then have the result of an Oracle query in XML form assigned to a variable using c:set:
    <c:set var="resultslist">
         <sql:dbQuery output="XML" bindParams="search">
                SELECT LISTID, ...
                FROM ...
                WHERE ...
                ORDER BY ...
         </sql:dbQuery>
    </c:set>      Now I can loop over the result using the following
              <x:parse xml="${resultslist}" var="listentry"/>
              <x:forEach select="$listentry/ROWSET/ROW" var="rowxml">
                   <x:out select="$rowxml/LISTID"/>
              </x:forEach>      So it appeared to me that the listentry variable resulting from x:parse xml="${resultslist}" was a node-set of parents of ROWSET. Then I tried:
              <x:parse xml="${resultslist}" var="listentry"/>
              <x:out select="name($listentry)"/>
              <x:out select="count($listentry)"/>
              <x:out select="count($listentry/ROWSET)"/>
              <x:out select="count($listentry/ROW)"/>      And the results were:
         ROWSET
         1
         0
         4           Four was the result I was looking for! So the solution was that the resultslist node-set was the ROWSET object in the <x:forEach> rather than its parent.
    Hope this helps someone.
    Andy Newton

  • Dom4j xpath problem

    Hello all
    I have several methods in which I noticed strange behavior
    Here is the example:
    I create xpath as object because of performance, cause i use it on thousands of files
    XPath pathSpanPodzakonska = DocumentHelper.createXPath("//span[@class='palnk']");
    I found h4 element via xpath with relative path to h4 element...
    That works fine so far and founds h4 element that I need to.
    final Element elementH4= (Element) document.selectSingleNode("//h4[@id='someId']");
    Now i need to found some element inside that h4 tag
    but what I get is first element in document, outside h4 element !!!
    final Node nodeSpanPodzakonska = pathSpanPodzakonska.selectSingleNode(elementH4);
    That works same even if i write
    final Node nodeSpanPodzakonska = elementH4.selectSingleNode("//span[@class='palnk']");
    If I write code with absolute xpath that works fine when the span is directly inside of h4 but this isn't always case and cant depend on that.
    And more important have some other similar methods and want to clarify what happens in this xpath implementations and how can I use it in the best way.
    final Node nodeSpanPodzakonska = elementH4.selectSingleNode("span[@class='palnk']");
    Danilo Cubrovic

    Sorry. I will have to think about the XPath question in more detail.
    As to the side by side comparison: I meant of - open source HTML parsers
    http://java-source.net/open-source/html-parsers
    and also of XML frameworks that support XPath (such as DOM4j vs XOM).
    I am going to try HTMLParser with XOM, as I have, in informal speed testing, seen HTMLParser to be quite fast compared to others.
    The reason I would like to have speed is that I am working on a Web automation toolkit:
    www.mkosh.com
    and it looks like I will be re-parsing the entire tree after many Javascript commands.
    I would like to make this as speedy as possible. HTMLParser seems to win hands down, although if it does not work with real world HTML, that could be an issue.
    I will have to test.
    Thank you so much
    Misha

  • Best way to perform the same task wih arrays of different Objects

    Hello all.
    This isn't an XPath question, it's a much lower-level Java Object question, but it involves XPath. I hope that doesn't distract from the question, or confuse anything.
    I have 4-5 different types of Objects (call them A, B, C, etc.) that each contain an array of other Objects (call them a[], b[], c[], etc.)
    a, b, c, etc., each have an Xpath object and and XPathExpression. When I create each XPath object I assign it a NamespaceContext object which contains the namespaces needed for that XPath.
    When I create, for example, an A object, I pass is constructor an array of a and an array of Namespaces. With each a object I need to:
    1. create a NamespaceContext object
    2. go through all the Namespace objects and if its route matches,
    (if Namespace.route == a.getRoute() )
    3. add that Namespace to the NamespaceContext Object,
    4. assign the NamespaceContext to the XPath object, and finally
    5. create the a object, passing it the XPath object
    My problem / question is: I also have to do the same thing with B and b[], C and c[], etc. It's not that long of a process, not that much code, but all the same, I was wondering what the best way to write this code once would be, and have it work for all the different types of Objects.
    In other words, I'd like to write a mehod, call it assignNamespaces(), that accepts an array of Objects(a[], b[], c[], etc.) and an array of Namespaces, creates the XPath Object for each a, b, c, etc., and that creates and returns an array of a[],b[],c[], etc., sending the XPath Object as a parameter.
    That way when I create for example an A Object, I call:
    class A
    ObjectsWithXpath[] objectsWithXPath;
    this..objectsWithXPath = assignNamespaces(objectsWithXPath,namespaces);
    Should the assgnNamespaces() method simply use Class.forName() to see what type of Object it is and do a cast accordingly, or is there some other, more elegant way of doing this?
    I hope I've explained myself, and haven't bored you ...
    Thanks in advance,
    Bob

    Thanks for your reply!
    I poked around a bit looking into Factory classes. I've used them a million times but never actually made one. At any rate, they seem like a good idea when you have a bunch of different classes that are similar but not equal.
    In my case my classes ONLY have the XPathExpression in common. Which means that I'd have to make a base abstract class with a bunch of methods of which only a percentage are defined by any class that extends it. In other words, if I had 3 classes -- a, b and c -- that extend the base abstract class, and each had 5 getters and setters, the base abstract class would have 15 methods, 5 only used by a, 5 only used by b and 5 only used by c.
    It seemed a bit ugly to me. Besides, I only have 3 classes. I decided to factor out the inner loop, which is about 70% of the code, stick it in a utility class, and call it from there. I am repeating some code still, but it isn't that bad, and it saves me having to define an interface, an abstract class, a Factory class, etc.
    It ain't perfect, but then nothing ever is.
    Thanks for all the help! Viva the Java community!
    Bob

  • Schema and Forms: Ex 1 Quiz missing XML sample

    XPath question is missing this XML:
    <x>
      <y z="abc"/>
    </x>
    Should be fixed soon.

    i tryied same way as you tried.
    no other parser are working. i guess oracle parser is best, but i dont no why other schema files are not working
    if any one have better solution help us, we are wasting days for these at final results are nonthing. please help us if you have solution
    srinu

  • OSB Split Join Repeat Until Question On XPath Condition

    I'm trying to use OSB File Transport to stream a very large XML document file into a service which will split the file into very many small XML documents. So, given a file like:
    <BookStore>
    <Book></Book>
    <Book></Book>
    ... (many more books)
    </BookStore>
    In the split join I want to use a 'repeat until' to process each Book until there are no more Books in the BookStore. Here's my question: What is the correct XPath expression to use as the Repeat Until terminating condition? (I'm an XPath novice.)
    Thanks for your help!!!

    Hi,
    Based on what I understood, you should be using a for each loop with the conditions as follows:
    Within the Split Join flow
    for each ( counter variable from 1 to Count (xpath of book) ) --> For my example it was count($request.parameter/sjpoc:Orders/sjpoc:Order) replace this with your xpath.
    - do your logic
    Snapshot just in case @ http://dl.dropbox.com/u/19901533/sj_foreach_snapshot.JPG
    Based on this the split and join would happen for n (based on count) number of Book tags.
    Let me know if my understanding is incorrect.
    Thanks,
    Patrick

  • XPath parsing question

    Hello,
    I have a problem that i wonder if its possible to solve using xalan xpath. I have a XML structure that looks like this:
    <ReferenceCoded>
    <type>AgreementType</type>
    <value>AgreementType1111</value>
    </ReferenceCoded>
    <ReferenceCoded>
    <type>Project</type>
    <value>Project11111</value>
    </ReferenceCoded>
    I want to use xpath to get the value of the Project referencecoded field, ie "Project11111" but i dont want to use ReferenceCoded[position=2] since i cant be sure of the order/the number of ReferenceCoded fields. Is there anyway i can use xpath to get the ReferenceCoded context that has a element <type> of value project?
    Thanks.

    by the way: the XPath i posted above works - i checked it with XPath Explorer which is a cool free tool (written in Java) to visually display results from XPaths. Good for testing!

  • Newbie questioni on XPath

    Hi all, I'm a newbie in JAVA programming and encountered a problem in XPath.
    My XML file is in the form like below:
    <Parent index="1">
    <Child name="A">11111</Child>
    <Parent index="2">
    <Child name="A">00000</Child>
    I managed to get the value of the child using
    (String) xPath.evaluate("//Parent@index='1'/Child", new InputSource(new FileReader(file)));
    But is there a way to get the value using a variable named "index" so I can choose which "parent" to obtain?
    (String) xPath.evaluate("//Parent@index='{color:#ff0000}index{color}'/Child", new InputSource(new FileReader(file)));
    Thanks.
    David

    I tried to use the above code but I encountered the following errors. Any ideas? Thanks.
    Exception in thread "main" javax.xml.transform.TransformerException: Expected ], but found:
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.error(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.consumeExpected(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.Predicate(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.Step(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.RelativeLocationPath(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.LocationPath(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.PathExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnionExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnaryExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.MultiplicativeExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.AdditiveExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.RelationalExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.EqualityExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.AndExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.OrExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.Expr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(Unknown Source)
         at com.sun.org.apache.xpath.internal.XPath.<init>(Unknown Source)
         at com.sun.org.apache.xpath.internal.XPath.<init>(Unknown Source)
         at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.eval(Unknown Source)
         at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(Unknown Source)
         at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(Unknown Source)
         at FusechainValidator.main(FusechainValidator.java:24)
    --------------- linked to ------------------
    javax.xml.xpath.XPathExpressionException
         at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(Unknown Source)
         at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.evaluate(Unknown Source)
         at FusechainValidator.main(FusechainValidator.java:24)
    Caused by: javax.xml.transform.TransformerException: Expected ], but found:
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.error(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.consumeExpected(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.Predicate(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.Step(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.RelativeLocationPath(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.LocationPath(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.PathExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnionExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnaryExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.MultiplicativeExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.AdditiveExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.RelationalExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.EqualityExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.AndExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.OrExpr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.Expr(Unknown Source)
         at com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(Unknown Source)
         at com.sun.org.apache.xpath.internal.XPath.<init>(Unknown Source)
         at com.sun.org.apache.xpath.internal.XPath.<init>(Unknown Source)
         at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.eval(Unknown Source)
         ... 3 more

Maybe you are looking for

  • My printer kicks all my other wireless devices offline when I connect it to my new router.

    I have the 6500 wireless printer (e709n model).  When I connect my printer to my home network it kicks all other devices that are connected offline (laptops, desktops, ipad, ipods, etc.).  If I turn the printer off and reset the modem then all those

  • Acrobat 9 on Windows 7 - cannot open

    At work we have a number of users running Windows 7 Pro x86 and Acrobat 9 Standard.  Within the past two weeks I've had 3 users running this setup complain to me that they've been periodically seeing an issue where they cannot open a PDF file.  After

  • Business Components and oracle.jbo.domain.Date

    Hello I have the next problem I have a Busines Component and I have to acess to rows who have Dates and with oracle.jbo.domain.Date I can4t acess to the day, month, year . Can anyone Help me how can I do to access this dates? Thanks a lot your your h

  • PIVOT TABLE

    This is the I/P: Feature Grouper_num 4 1 5 2 6 2 7 1 7 0 8 1 8 0 9 2 10 2 10 0 11 1 11 2 11 0 This is the desired output: Feature subfeature value 4 5 4 6 7 7 8 8 8 9 8 10 10 11 11 11 If we observe table 1 feature 4 is parent for 5 & 6 feature and 7

  • Adobe Dreamweaver CC won't Exit

    Hello, I have downloaded Adobe Dreamweaver CC Trail 64bit. It is installed successfully on WIndows7 64 bit. The problem is when I try to exit it won't exit. Exit button dose't work. also in File me Exit command dose't work. Please send me if any solu