Monday, 30 October 2017

[XML/Saxon7] Saxon could not evaluate XQuery: Error on line xyz A sequence of more than one item is not allowed as the 19th argument of concat()

I wanted to extract information from a software generated XML using XQuery by the according jEdit plugin. However, I could not find a real work-around for mentioned error. I believe that the cause is the name of a specific XML element of the document I want to query.
Interesting part of the XML document:
            <sessionextension name="Relational Writer" sinstancename="KDS_E_PART_PARTEI" subtype="Relational Writer" transformationtype="Target Definition" type="WRITER">
                <connectionreference cnxrefname="DB Connection" connectionname="" connectionnumber="1" connectionsubtype="" connectiontype="Relational" variable="$DBConnection_Tgt">
                <attribute name="Target load type" value="Bulk">
                <attribute name="Insert" value="YES">
                <attribute name="Update as Update" value="NO">
                <attribute name="Update as Insert" value="NO">
                <attribute name="Update else Insert" value="NO">
                <attribute name="Delete" value="NO">
                <attribute name="Truncate target table option" value="YES">
</attribute></attribute></attribute></attribute></attribute></attribute></attribute></connectionreference></sessionextension>
It is the ATTRIBUTE element. So my working query is
(: constant definition :)
   let $indent := "   "
   let $linebreak := "&#xa;"

(: main :)
   (: walk the worklets :)
   for $writer in /POWERMART/REPOSITORY/FOLDER/WORKLET/SESSION/SESSIONEXTENSION[@TYPE = "WRITER" and (starts-with(@SINSTANCENAME, "KDS_E_") or starts-with(@SINSTANCENAME, "KDS_I_") or starts-with(@SINSTANCENAME, "KDS_S_") or starts-with(@SINSTANCENAME, "KDS_T_"))]
   where ($writer/CONNECTIONREFERENCE[@VARIABLE != "$DBConnection_Staging"] and $writer/ATTRIBUTE[@NAME = "Truncate target table option" and @VALUE = "YES"])
   return
      concat($writer/../../@NAME
            ,$linebreak
            ,$indent
            ,$writer/../@NAME
            ,$linebreak
            ,$indent
            ,$indent
            ,$writer/@SINSTANCENAME
            ,$linebreak
            ,$indent
            ,$indent
            ,$indent
            ,"Connection: "
            ,$writer/CONNECTIONREFERENCE/@VARIABLE
            ,$linebreak
            ,$indent
            ,$indent
            ,$indent
            ,"Truncate target table option: YES"
      )
Initially I tried to have the analogous solution to the CONNECTIONREFERENCE solution for the ATTRIBUTE element but within the concat function it throws mentioned exception

No comments:

Post a Comment

[git] Create a local branch from another branch

From the active branch git checkout -b <LOCAL_BRANCH> From a donator branch git checkout -b <LOCAL_BRANCH> <DONATING_BRANCH...