xpath expression evaluation does not work in 8.1.2

I have tried the following simple xml:



<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
             xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="MonitorServiceCache">

        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

        <properties>
            <property name="eclipselink.jdbc.driver" value="org.h2.Driver"/>
            <property name="eclipselink.jdbc.url" value="jdbc:h2:mem:monitorServiceDB"/>
            <!-- I work in this example without user / password.-->
            <property name="eclipselink.jdbc.user" value="monitorServiceCache"/>
            <property name="eclipselink.jdbc.password" value=""/>

            <!-- EclipseLink should create the database schema automatically -->

            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
            <property name="eclipselink.ddl-generation.output-mode" value="database"/>
            <property name="eclipselink.target-database" value="HSQL"/> <!--Is this necessary???-->
        </properties>

    </persistence-unit>
</persistence>



 

and the following simple xpath expression fails:

/persistence/persistence-unit

Bug?


 
2 comments
Comment actions Permalink

Hello Saqib,

and the following simple xpath expression fails:

/persistence/persistence-unit

Bug?


No, this is correct. There is no default namespace in XPath, so you need to configure a prefix, e.g.
"p" for the URI "http://java.sun.com/xml/ns/persistence" (switch to Advanced Mode, "Edit
Context...") and use it in your query like this:

/p:persistence/p:persistence-unit

Sascha

0
Comment actions Permalink

Ah - that works! Thanks!

I figured there must have been something that I missed right after I submitted the question! :-\

0

Please sign in to leave a comment.