我有一個關於從XML xpath獲取數據的查詢。Scriptella:如何處理錯誤,同時通過Xpath從XML中獲取數據
<query connection-id="in">
CommunicationCenter/Response/MenuData/Menu/Noun
<!--something I have to do inside script using the data fetched from xpath-->
</query>
我的問題是 - 假設1的XML沒有這種Xpath結構。它有「OtherCommCenter/MenuData/Menu/Noun」或其他結構。然後,當我運行這個作業時,它說這個作業執行時沒有異常&,因爲它沒有從xpath獲得任何值,也沒有發生任何事情。意味着它返回null。那麼,我該如何捕捉錯誤?我必須知道xpath中的哪個元素會產生問題,或者如果這是不可能的,至少哪個xml會在結構中創建此錯誤?
(,因爲在我的項目中,有多個個XML我要處理&我做的,通過作業提交給ExecutorService的就像你在How to ETL multiple files using Scriptella?描述)
附:對於最後一部分,我是這樣做的
<connection id="in" driver="xpath" url="$input"/>
其中「input」是不同xml文件名的映射關鍵字。
有人可以幫我嗎?有必要儘快知道我的項目。
我害怕我不跟隨這裏的實際問題。你不能爲你正在處理的每種類型的XML編寫單獨的ETL。因此,在您使用OtherCommCenter XML的示例中,您可以簡單地使用OtherCommCenter/MenuData/Menu/Noun進行查詢。帶有CommunicationCenter/Response/MenuData/Menu/Noun查詢的ETL文件將簡單地忽略在根處沒有的xml。 –
ejboy
@ejboy我在一個新的帖子中改寫了這個問題。請考慮一下。 – user1838450