IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Export XML data based on specific data condigion Options · View
bmacbmac
Posted: Sunday, October 16, 2016 10:54:40 PM
Rank: Member

Joined: 11/14/2011
Posts: 15
Location: Coeur D Alene, iD
Hello. I am sure there is an easy way to do this, I am just missing a step. I am exporting XML data to an SQL database. I have several fields, including Docket_ID where I only want to export records where the Docket_ID is like 40*.

I have tried inserting the 'Filter' and a Constant '40*', but getting errors and I'm sure this is incorrect. Can someone recommend what I should insert here to do this?

Thanks!


bmacbmac attached the following image(s):
Capture.JPG

island
Posted: Monday, October 17, 2016 9:34:38 AM
Rank: Newbie

Joined: 10/28/2002
Posts: 1,283
Location: AT
Hi,

use an SQL WHERE component
bmacbmac
Posted: Monday, October 17, 2016 8:31:57 PM
Rank: Member

Joined: 11/14/2011
Posts: 15
Location: Coeur D Alene, iD
I tried using that, but my source data is XML and I am mapping/exporting to an SQL database. Can I use 'SQL Where' if my source data is XML? If so, I'll keep playing with it.
island
Posted: Tuesday, October 18, 2016 7:44:31 AM
Rank: Newbie

Joined: 10/28/2002
Posts: 1,283
Location: AT
My mistake, I thought you were exporting from a database. You cannot use an SQL where if your source is an xml file.

The screenshot below makes the assumption that you you want to filter values that begin with 40 followed by 0 or more additional characters.

Using the match-pattern function you can filter the correct nodes accordingly.


Code:


40[0-9a-zA-Z]*



File Attachment(s):
test.zip (2kb) downloaded 803 time(s).

island attached the following image(s):
match-pattern.png

mkirkpatrick
Posted: Tuesday, October 18, 2016 6:04:58 PM
Rank: Newbie

Joined: 10/17/2016
Posts: 6
A bit more simply, there is a function called "starts-with". This allows you to check if the value starts with a given substring.

Just so you are aware, this is a string function, so your input value will be converted to a string, but it can do this implicitly so that poses no problem.

Also, using the regular expression the other poster provided would assume that your input value only has standard alphanumeric characters, so you would have to adjust it if you needed any symbols or accented characters. Using starts-with will avoid this potential issue altogether. If you had more complex requirements, match-pattern would be the way to go, but it's not strictly necessary in this case. :)
island
Posted: Wednesday, October 19, 2016 4:09:54 PM
Rank: Newbie

Joined: 10/28/2002
Posts: 1,283
Location: AT
Quote:

Also, using the regular expression the other poster provided would assume that your input value only has standard alphanumeric characters, so you would have to adjust it if you needed any symbols or accented characters.


This is correct. To take account of non standard characters as well the following regex could be used with the match-pattern function.

Code:
40.*
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.