problem with namespace

Monday, 1 October 2018 · 2 messages · last reply 2 Oct 2018
R
radim-havlicek1 Oct 2018 15:49 #
Hello, I have problem with namespace 'www.ni.com/TestStand/ATMLTestResults/3.0'. It works for "return" statement, but when I use a value from this namespace in "where" or "order by" statement, the query returns just an empty string, like no results would have been found, although they exist. In more detail, I have following query: -----------------------------------------------
declare namespace nTestResultsCollection='urn:IEEE-1636.1:2013:
TestResultsCollection';

declare namespace nTestResults='urn:IEEE-1636.1:2013:TestResults';

declare namespace nCommon='urn:IEEE-1671:2010:Common';

declare namespace nNi='www.ni.com/TestStand/ATMLTestResults/3.0';
let $DocumentNames := ('Report/89500019-0000-4020-a039-9f53a80d7058', 'Report/89400019-0052-4020-a0f0-e1851b8bbec2', 'Report/00000000-0000-4020-a 093-6c29d4c65c32', 'Report/00000000-0000-4020-a09c-ac632bfa5a7d', 'Report/ 00000000-0000-4020-a09c-ac635023a45c', 'Report/00000000-0000-4020-a09c-ac63e 9c5b490', 'Report/89500019-0051-4020-a170-409bbe8e4f89', 'Report/89500019- 0051-4020-a170-409b334e86c8')
for $DocumentName in $DocumentNames

let $Document := db:open('ATML',$DocumentName)
let $TestSystemItem0 := $Document/nTestResultsCollection: TestResultsCollection/nTestResultsCollection:TestResults/nTestResults: TestStation/nCommon:Definition/nCommon:Identification/nCommon:ModelName/text () let $TestSystemItem1 := $Document/nTestResultsCollection: TestResultsCollection/nTestResultsCollection:TestResults/nTestResults: TestStation/nCommon:Definition/nCommon:Extension/nNi:Items/nNi:Item/Content/ text() let $StartDate := $Document/nTestResultsCollection:TestResultsCollection/ nTestResultsCollection:TestResults/nTestResults:ResultSet/substring-before (data(@startDateTime), 'T') let $StartTime := $Document/nTestResultsCollection:TestResultsCollection/ nTestResultsCollection:TestResults/nTestResults:ResultSet/substring-after (data(@startDateTime), 'T') let $UUID := $Document/nTestResultsCollection:TestResultsCollection/ nTestResultsCollection:TestResults/data(@uuid) let $Serial_Number := $Document/nTestResultsCollection: TestResultsCollection/nTestResultsCollection:TestResults/nTestResults:UUT/ nCommon:SerialNumber/text() let $Part_Number := $Document/nTestResultsCollection:TestResultsCollection/ nTestResultsCollection:TestResults/nTestResults:UUT/nCommon:Definition/data( @name) let $Slot_ID := $Document/nTestResultsCollection:TestResultsCollection/ nTestResultsCollection:TestResults/nTestResults:TestStation/nCommon: Definition/nCommon:Extension/nNi:Items/nNi:Item/Content/text() where (($TestSystemItem1 = 'dx5484')) order by $StartDate, $StartTime return
<Result>

  <DocumentName>{ $DocumentName }</DocumentName>

  <TestSystemItem0>{ $TestSystemItem0 }</TestSystemItem0>

  <TestSystemItem1>{ $TestSystemItem1 }</TestSystemItem1>

  <StartDate>{ $StartDate }</StartDate>

  <StartTime>{ $StartTime }</StartTime>

  <Serial_Number>{ $Serial_Number }</Serial_Number>

  <Part_Number>{ $Part_Number }</Part_Number>

  <Slot_ID>{ $Slot_ID }</Slot_ID>

  <Additional_Info></Additional_Info>

  <ChildResults>

  {
let $Childs := $Document/nTestResultsCollection:TestResultsCollection/ nTestResultsCollection:TestResults/nTestResults:ResultSet//nTestResults: TestGroup/nTestResults:Test
    for $Test in $Childs

    let $TestData := $Test/nTestResults:TestResult/nTestResults:TestData
let $Limits := $Test/nTestResults:TestResult/nTestResults:TestLimits/ nTestResults:Limits
    let $TestId := $Test/data(@ID)

    let $TestName := $Test/data(@name)

    let $TestGroup := $Test/../substring-after(data(@name), '#')

    let $TestOutcome := $Test/nTestResults:Outcome/data(@value)

    let $Root := $Test/root()
let $RootUuid := $Root/nTestResultsCollection:TestResultsCollection/ nTestResultsCollection:TestResults/data(@uuid)
    where (($TestName = 'Course Datum MON (7V)' and $TestGroup = 'Course
Datum Input Test' and $RootUuid = $UUID))
return
    <Test>

      <TestData>{ $TestData }</TestData>

      <Limits>{ $Limits }</Limits>

      <TestId>{ $TestId }</TestId>

      <TestName>{ $TestName }</TestName>

      <TestGroup>{ $TestGroup }</TestGroup>

      <TestOutcome>{ $TestOutcome }</TestOutcome>

      <Temperature></Temperature>

    </Test>
}
  </ChildResults>

</Result>
----------------------------------------------- If I remove the where (($TestSystemItem1 = 'dx5484')) statement ($ TestSystemItem1 is from nNi namespace), it works fine and TestSystemItem1 values are returned properly in the result in the <TestSystemItem1>{ $ TestSystemItem1 }</TestSystemItem1>. However, if I put the $TestSystemItem1 to the where statement (like in the example above), or to the order by statement, it returns empty result. Is there a way how to fix it? Or is it fixable in the BaseX itself (maybe in the new version)? We cannot change the value of 'www.ni.com/TestStand/ ATMLTestResults/3.0' because the xml files are generated by the 3rd party. Thank you for your help in advance. Best regards, Radim Havlicek
CG
Christian Grün2 Oct 2018 13:33 #
Hi Radim, Thanks for the observation. Could you possibly provide us a little self-contained example (e.g. with a single document that we can use for creating a database) and drop the lines of code that are not necessary to understand the problem? Thanks in advance, Christian
Quoted text · PM · 84 lines
On Mon, Oct 1, 2018 at 3:49 PM <radim-havlicek at post.cz> wrote: > > Hello, > > I have problem with namespace 'www.ni.com/TestStand/ATMLTestResults/3.0'. It works for "return" statement, but when I use a value from this namespace in "where" or "order by" statement, the query returns just an empty string, like no results would have been found, although they exist. > > In more detail, I have following query: > ----------------------------------------------- > > declare namespace nTestResultsCollection='urn:IEEE-1636.1:2013:TestResultsCollection'; > declare namespace nTestResults='urn:IEEE-1636.1:2013:TestResults'; > declare namespace nCommon='urn:IEEE-1671:2010:Common'; > declare namespace nNi='www.ni.com/TestStand/ATMLTestResults/3.0'; > > let $DocumentNames := ('Report/89500019-0000-4020-a039-9f53a80d7058', 'Report/89400019-0052-4020-a0f0-e1851b8bbec2', 'Report/00000000-0000-4020-a093-6c29d4c65c32', 'Report/00000000-0000-4020-a09c-ac632bfa5a7d', 'Report/00000000-0000-4020-a09c-ac635023a45c', 'Report/00000000-0000-4020-a09c-ac63e9c5b490', 'Report/89500019-0051-4020-a170-409bbe8e4f89', 'Report/89500019-0051-4020-a170-409b334e86c8') > for $DocumentName in $DocumentNames > let $Document := db:open('ATML',$DocumentName) > let $TestSystemItem0 := $Document/nTestResultsCollection:TestResultsCollection/nTestResultsCollection:TestResults/nTestResults:TestStation/nCommon:Definition/nCommon:Identification/nCommon:ModelName/text() > let $TestSystemItem1 := $Document/nTestResultsCollection:TestResultsCollection/nTestResultsCollection:TestResults/nTestResults:TestStation/nCommon:Definition/nCommon:Extension/nNi:Items/nNi:Item/Content/text() > let $StartDate := $Document/nTestResultsCollection:TestResultsCollection/nTestResultsCollection:TestResults/nTestResults:ResultSet/substring-before(data(@startDateTime), 'T') > let $StartTime := $Document/nTestResultsCollection:TestResultsCollection/nTestResultsCollection:TestResults/nTestResults:ResultSet/substring-after(data(@startDateTime), 'T') > let $UUID := $Document/nTestResultsCollection:TestResultsCollection/nTestResultsCollection:TestResults/data(@uuid) > let $Serial_Number := $Document/nTestResultsCollection:TestResultsCollection/nTestResultsCollection:TestResults/nTestResults:UUT/nCommon:SerialNumber/text() > let $Part_Number := $Document/nTestResultsCollection:TestResultsCollection/nTestResultsCollection:TestResults/nTestResults:UUT/nCommon:Definition/data(@name) > let $Slot_ID := $Document/nTestResultsCollection:TestResultsCollection/nTestResultsCollection:TestResults/nTestResults:TestStation/nCommon:Definition/nCommon:Extension/nNi:Items/nNi:Item/Content/text() > > > where (($TestSystemItem1 = 'dx5484')) > order by $StartDate, $StartTime > > return > <Result> > <DocumentName>{ $DocumentName }</DocumentName> > <TestSystemItem0>{ $TestSystemItem0 }</TestSystemItem0> > <TestSystemItem1>{ $TestSystemItem1 }</TestSystemItem1> > <StartDate>{ $StartDate }</StartDate> > <StartTime>{ $StartTime }</StartTime> > <Serial_Number>{ $Serial_Number }</Serial_Number> > <Part_Number>{ $Part_Number }</Part_Number> > <Slot_ID>{ $Slot_ID }</Slot_ID> > <Additional_Info></Additional_Info> > > > <ChildResults> > { > let $Childs := $Document/nTestResultsCollection:TestResultsCollection/nTestResultsCollection:TestResults/nTestResults:ResultSet//nTestResults:TestGroup/nTestResults:Test > for $Test in $Childs > let $TestData := $Test/nTestResults:TestResult/nTestResults:TestData > let $Limits := $Test/nTestResults:TestResult/nTestResults:TestLimits/nTestResults:Limits > let $TestId := $Test/data(@ID) > let $TestName := $Test/data(@name) > let $TestGroup := $Test/../substring-after(data(@name), '#') > let $TestOutcome := $Test/nTestResults:Outcome/data(@value) > let $Root := $Test/root() > let $RootUuid := $Root/nTestResultsCollection:TestResultsCollection/nTestResultsCollection:TestResults/data(@uuid) > > > where (($TestName = 'Course Datum MON (7V)' and $TestGroup = 'Course Datum Input Test' and $RootUuid = $UUID)) > return > <Test> > <TestData>{ $TestData }</TestData> > <Limits>{ $Limits }</Limits> > <TestId>{ $TestId }</TestId> > <TestName>{ $TestName }</TestName> > <TestGroup>{ $TestGroup }</TestGroup> > <TestOutcome>{ $TestOutcome }</TestOutcome> > <Temperature></Temperature> > > </Test> > } > </ChildResults> > > </Result> > > ----------------------------------------------- > > If I remove the where (($TestSystemItem1 = 'dx5484')) statement ($TestSystemItem1 is from nNi namespace), it works fine and TestSystemItem1 values are returned properly in the result in the <TestSystemItem1>{ $TestSystemItem1 }</TestSystemItem1>. However, if I put the $TestSystemItem1 to the where statement (like in the example above), or to the order by statement, it returns empty result. > > Is there a way how to fix it? Or is it fixable in the BaseX itself (maybe in the new version)? We cannot change the value of 'www.ni.com/TestStand/ATMLTestResults/3.0' because the xml files are generated by the 3rd party. > > Thank you for your help in advance. > Best regards, > > Radim Havlicek

⚡Generated with XQuery