Good suggestion. I have just added tops:split for the next release.  
Example:

        ?str tops:split ("AAA BB    CC   " " ") .

will bind ?str with
AAA
BB
CC

The second argument is a regular expression. Since empty strings will  
be ignored, no trim is needed IMHO.

Holger


On May 21, 2009, at 6:24 AM, Smith, Tim wrote:

>
> Hi Phil,
>
> I also did not see a function that will split a string based on a  
> delimiter in the latest version.  I need to split strings based on  
> arbitrary delimiters all the time so I wrote a split string function  
> in java and made it a property function to use in CONSTRUCT queries.
>
> In addition to splitting strings it also takes a parameter that when  
> TRUE, automatically trims the strings of leading/trailer whitespace  
> before returning them.  This is very useful since you would likely  
> need to trim each one before using it to generate a URI, etc.
>
> It would be a very helpful function to have in the base product.
>
> Tim
>
>
>> -----Original Message-----
>> From: [email protected] [mailto:topbraid-
>> [email protected]] On Behalf Of [email protected]
>> Sent: Thursday, May 21, 2009 8:05 AM
>> To: TopBraid Composer Users
>> Subject: [tbc-users] Re: How to extract multiple values from a space-
>> delimited string?
>>
>>
>> Scott -
>>
>> I know how to use the string function to separate a SINGLE string  
>> out,
>> but how do I get them ALL parsed out given that the number of
>> individual elements is unknown (i.e. one drug might be related to 3
>> others and another drug might have 17 related drugs)?
>>
>> On May 21, 8:01 am, Scott Henninger <[email protected]>
>> wrote:
>>> Phil, the "BBB CCC..." string will need to be parsed an individually
>>> turned into URIs.  See the String Functions in the SPARQLMotion
>>> Functions Reference in the Help files.
>>>
>>> -- Scott
>>>
>>> On May 21, 7:56 am, [email protected] wrote:
>>>
>>>
>>>
>>>> I have a sparql motion script that iterates over a series of xml
>> files
>>>> (1 drug per file), converts the XML into RDF, and creates instances
>> of
>>>> the classes/properties from an ontology.  One of the elements
>> within
>>>> the xml is a series space-separated values that I need to parse
>> into
>>>> individual triples of a given property. Here is a simple example:
>>>
>>>>   <?xml version="1.0" encoding="UTF-8" ?>
>>>> <Drug ID="AAA">
>>>>   <DrugName>
>>>>     <![CDATA[ dummy ]]>
>>>>   </DrugName>
>>>>   <RelatedDrug>
>>>>     <![CDATA[  BBB CCC DDD EEE FFF GGG ]]>
>>>>   </RelatedDrug>
>>>> </Drug>
>>>
>>>> I need to generate triples like the following:
>>>
>>>>      :AAA a :Drug .
>>>>      :AAA :hasName "dummy" .
>>>>      :AAA :isRelatedTo :BBB .
>>>>      :AAA :isRelatedTo :CCC .
>>>>      :AAA :isRelatedTo :DDD .
>>>>      :AAA :isRelatedTo :EEE .
>>>>      :AAA :isRelatedTo :FFF .
>>>>      :AAA :isRelatedTo :GGG .
>>>
>>>> The number of related drugs will differ from drug to drug (i.e.
>> file
>>>> to file).  The files are being processed via an IterateOverSelect
>>>> module where the body of that module is a series of construct
>> modules
>>>> that produce the individual triples you see above.  However, what I
>> am
>>>> getting now is:
>>>
>>>>      :AAA a :Drug .
>>>>      :AAA :hasName "dummy" .
>>>>      :AAA :isRelatedTo :BBB_CCC_DDD_EEE_FFF_GGG  .
>>>
>>>> How can I split that last element up into individual triples?
>>>
>>>> Phil- Hide quoted text -
>>>
>>> - Show quoted text -
>>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TopBraid Composer Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/topbraid-composer-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to