Dear Christian,

Thanks a lot for your suggestions. 

But as I stated in my original mail, I didn't plan to translate schema 
definitions to regular expressions...
Neither did the validation module work as I hoped: Unfortunately the element in 
question is defined locally, not globally ("Validation failed: Deklaration des 
Elements 'BIC' kann nicht gefunden warden."). 

So, back to regex, I suppose!

Best regards,
Ulrike.

-----Ursprüngliche Nachricht-----
Von: Christian Grün [mailto:[email protected]] 
Gesendet: Freitag, 11. März 2016 11:29
An: Ulrike Schaper <[email protected]>
Cc: [email protected]
Betreff: Re: [basex-talk] How to check an element's type against an XSD simple 
type

Sorry, a last one: Here is the fixed version of the query:

declare variable $BIC-PATTERN :=
'^[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}$';
let $node := <BIC>GEN0DEM1MPW</BIC>
return if(matches($node, $BIC-PATTERN)) then 'well done' else 'sigh'

Most importantly, you’ll have to wrap your regex pattern with ^ and $ in order 
to ensure that there are no other heading or trailing characters in the BIC 
string.


On Fri, Mar 11, 2016 at 11:23 AM, Christian Grün <[email protected]> 
wrote:
> PS: If it’s only about BIC validation, you can obviously use standard XQuery:
>
> declare variable $BIC-PATTERN :=
> '[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}';
> let $node := <BIC>GEN0DEM1MPW</BIC>
> return if(matches($node, $BIC-) then 'well done' else 'sigh'
>
>
>
>
> On Fri, Mar 11, 2016 at 11:20 AM, Christian Grün 
> <[email protected]> wrote:
>> Hi Ulrike,
>>
>> The Validation Module should help you here, in particular 
>> validate:xsd-report [1]. It allows you to pass on file URIs or XML 
>> fragments as arguments.
>>
>> All the best,
>> Christian
>>
>> [1] http://docs.basex.org/wiki/Validation_Module
>>
>>
>>
>> On Fri, Mar 11, 2016 at 10:02 AM, Ulrike Schaper - SideStep Business 
>> Solutions GmbH <[email protected]> wrote:
>>> Hi everybody,
>>>
>>>
>>>
>>> I’m trying to compose XML documents for SEPA transactions via BaseX.
>>>
>>> I would like to check certain data against the corresponding schema 
>>> before putting them into the document, e.g. BIC identifiers.
>>>
>>>
>>>
>>> In the xsd, there’s a simpleType definition for BICs:
>>>
>>>                 <xs:simpleType name="BICIdentifier">
>>>
>>>                                <xs:restriction base="xs:string">
>>>
>>>                                                <xs:pattern 
>>> value="[A-Z]{6,6}[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3,3}){0,1}"/>
>>>
>>>                                </xs:restriction>
>>>
>>>                 </xs:simpleType>
>>>
>>>
>>>
>>> I hoped it would be as simple as
>>>
>>>
>>>
>>> declare default element namespace
>>> "urn:iso:std:iso:20022:tech:xsd:pain.001.003.03";
>>>
>>> let $node := <BIC>GEN0DEM1MPW</BIC>
>>>
>>> return if(string($node) instance of BICIdentifier) then (true() (:
>>> process... :)) else (false() (: report error :))
>>>
>>>
>>>
>>> But, as I learned now, BaseX doesn’t support import of schemas. 
>>> Thus, I receive the error message “Unknown type:
>>> Q{urn:iso:std:iso:20022:tech:xsd:pain.001.003.03 }BICIdentifier”.
>>>
>>>
>>>
>>> Is there some workaround (other than rebuilding regular expressions 
>>> from schema to xquery)?
>>>
>>>
>>>
>>> Best regards,
>>>
>>> Ulrike.

Reply via email to