.attribute()

Description of the method
Description:

.attribute() returns raw attribute information for any element e.g. xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

.attribute("xmlns") returns the attribute value for xmlns e.g. urn:iso:std:iso:20022:tech:xsd:pain.001.001.03

Available for:

any element

Parameters: attribute name 
Return type: string

 

Example 1

Context: Document
OCL: self.attribute("xmlns").matches("urn:iso:std:iso:20022:tech:xsd:pain.001.001.03")
Description: The example rule checks if xmlns has value "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03".

 

The XML snippet below would pass this check.

<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

The other snippet below however would not pass this check as the value is different from "urn:iso:std:iso:20022:tech:xsd:pain.001.001.03".

<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.09" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

 

Example 2

Context: Document
OCL: not(self.attribute().matches('.*[\"].*'))
Description: The example rule checks that the attribute information does not contain any double quotation marks.

 

The XML snippet below would pass this check.

<Document xmlns='urn:iso:std:iso:20022:tech:xsd:pain.001.001.03' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>

The other snippet below however would not pass this check as the double quotation marks are used for the attribute values.

<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">