2013-07-14 28 views
1

我是SAX和Java的新手,實現了SAX默認處理程序並讀取了xml文件。 當startElement被調用一個xml節點,該節點具有名稱空間聲明作爲屬性 xmlns屬性在SAX處理程序的startElement回調屬性中不存在

<schema xmlns="http://www.w3.org/2001/XMLSchema" 
    xmlns:tranPurch="urn:purchases_2013_1.transactions.webservices.netsuite.com" 
    xmlns:tranPurchTyp="urn:types.purchases_2013_1.transactions.webservices.netsuite.com" 
    xmlns:platformCore="urn:core_2013_1.platform.webservices.netsuite.com" 
    xmlns:platformCoreTyp="urn:types.core_2013_1.platform.webservices.netsuite.com" 
    xmlns:platformCommon="urn:common_2013_1.platform.webservices.netsuite.com" 
    xmlns:platformCommonTyp="urn:types.common_2013_1.platform.webservices.netsuite.com" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="urn:purchases_2013_1.transactions.webservices.netsuite.com" 
    elementFormDefault="qualified" > 

startElement被調用這個XML節點,我只看到裏面attributestargetNamespaceelementFormDefault 如何獲得命名空間聲明,以及2個屬性?例如,我想要做這樣的事情。

String val = attributes.getValue("xmlns:tranPurch"); 

我期待valurn:purchases_2013_1.transactions.webservices.netsuite.com

回答

3

空間聲明所使用的startPrefixMapping()和的endPrefixMapping()回調通知的ContentHandler。

+0

非常感謝。這正是我正在尋找的。 – Partha