Zum Inhalt springen

xPath :: NamespaceContext


Empfohlene Beiträge

Geschrieben

Hallo,

ich habe eine beispiels XML-Datei:


<?xml version="1.0" encoding="ISO-8859-1"?>

        <root xmlns="http://www.softlab.de/2006/IOML"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.softlab.de/2006/IOML ioml_iocmd.xsd" >

                <command>

                        <title>Command-Test Nr.1</title>

                        <datum>2007.08.28</datum>

                        <a_1>1</a_1>

                        <a_2>11</a_2>

                </command>

        </root>

um diese Datei zu evaluate() muss ich das Interface NamespaceContext implementieren (wegen xmlns="http://www.softlab.de/2006/IOML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.softlab.de/2006/IOML ioml_iocmd.xsd"):

public class NamespaceContextImpl implements NamespaceContext {


    public String getNamespaceURI(String prefix){

    	logger.info("==|> getNamespaceURI("+prefix+")");


    	if (prefix.equals("xml"))

            return "http://www.w3.org/2001/XMLSchema-instance";

        else if (prefix.equals("schemaLocation"))

        	return "http://www.softlab.de/2006/IOML ioml_iocmd.xsd";

        else

            return XMLConstants.DEFAULT_NS_PREFIX;

    }


    // This method isn't necessary for XPath processing.

    public String getPrefix(String uri) {

        throw new UnsupportedOperationException();

    }


    // This method isn't necessary for XPath processing either.

    public Iterator getPrefixes(String uri) {

        throw new UnsupportedOperationException();

    }

}

Das Problem ist wenn ich in der XML-Datei in dem root-Tag das (xmlns="http://www.softlab.de/2006/IOML" ) weglasse bekommen ein Ergebniss, wenn ich aber das (xmlns="http://www.softlab.de/2006/IOML" ) in dem root-Tag einfühge habe ich plötzlich kein Ergebniss mehr !?!?

xPath: //command/a_1/text()

Weist vielleicht jemad woran es liegen könnte??? :confused:

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...