Ivan Yakushev Valued Contributor.
Valued Contributor.
743 views

XML Parser issue

Jump to solution

Hi, all,

Good day. I'm having issue with parsing XML content in a flex file connector. My string-join() function ignores a separator (','  or '\|' for example), i dont know why.

There is my XML:

<v8e:Event>

     <v8e:Data>

            <v8e:OSAuthentication>false</v8e:OSAuthentication>

            <v8e:StandardAuthentication>false</v8e:StandardAuthentication>

            <v8e:CannotChangePassword>false</v8e:CannotChangePassword>

            <v8e:Name>TestUser</v8e:Name>

            <v8e:Language>Language.Russian</v8e:Language>

            <v8e:PasswordChanged>false</v8e:PasswordChanged>

            <v8e:PasswordIsSet>false</v8e:PasswordIsSet>

            <v8e:ShowInList>true</v8e:ShowInList>

            <v8e:FullName>TestUser</v8e:FullName>

            <v8e:OSUser>\\1\1</v8e:OSUser>

            <v8e:RunMode>Auto</v8e:RunMode>

            <v8e:Roles/>

      </v8e:Data>

  <v8e:DataPresentation/>

  <v8e:TransactionStatus>NotApplicable</v8e:TransactionStatus>

  <v8e:TransactionID/>

  <v8e:Connection>3</v8e:Connection>

  <v8e:Session>10</v8e:Session>

  <v8e:ServerName/>

  <v8e:Port>0</v8e:Port>

  <v8e:SyncPort>0</v8e:SyncPort>

</v8e:Event>

Part of parser with string-join() function:

# Data

token[23].name=Data

token[23].type=String

token[23].expression=string-join(v8e:Data, '\|')

token[23].node=.

event.deviceCustomString2Label=__stringConstant("Data")

event.deviceCustomString2=Data

I expect to see string like "false|false|false|TestUser|Language.Russian|false|false|true|TestUser|\\1\1|Auto", but i've got: "falsefalsefalseTestUserLanguage.RussianfalsefalsetrueTestUser\\1\1Auto"

Can someone help?

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Ivan Yakushev Valued Contributor.
Valued Contributor.

Re: XML Parser issue

Jump to solution

Finally, i found a solution. The problem was in the wrong Xquery.

The correct one XQuery is:

token[23].expression=if (fn:empty(v8e:Data)) then () else fn:string-join((v8e:Data/*//text()[normalize-space()]), "|")

A good site for testing XQuery and XPath: Simple online XQuery tester

2 Replies
Highlighted
bkilroe Super Contributor.
Super Contributor.

Re: XML Parser issue

Jump to solution

Hi Ivan,

Have you tried double escaping the pipe character e.g. \\|

So your line :token[23].expression=string-join(v8e:Data, '\|')

would become token[23].expression=string-join(v8e:Data, '\\|')

0 Likes
Ivan Yakushev Valued Contributor.
Valued Contributor.

Re: XML Parser issue

Jump to solution

Finally, i found a solution. The problem was in the wrong Xquery.

The correct one XQuery is:

token[23].expression=if (fn:empty(v8e:Data)) then () else fn:string-join((v8e:Data/*//text()[normalize-space()]), "|")

A good site for testing XQuery and XPath: Simple online XQuery tester

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.