@@ -1735,6 +1735,13 @@ export class ExampleGenerator extends AmfHelperMixin(Object) {
17351735 this . ns . w3 . shacl . name
17361736 ) ) ;
17371737 }
1738+ if ( serialization ) {
1739+ if ( xmlAttribute ) {
1740+
1741+ this . _appendXmlAttribute ( node , range , xmlName , examples [ 0 ] ) ;
1742+ return ;
1743+ }
1744+ }
17381745 this . _xmlFromExamples ( doc , node , examples [ 0 ] , name , { xmlPrefix } ) ;
17391746 return ;
17401747 }
@@ -1818,7 +1825,7 @@ export class ExampleGenerator extends AmfHelperMixin(Object) {
18181825 * @param {Object } range AMF range
18191826 * @param {String } xmlName Value of 'xmlName' property of AMF's object
18201827 */
1821- _appendXmlAttribute ( node , range , xmlName ) {
1828+ _appendXmlAttribute ( node , range , xmlName , example ) {
18221829 let name = /** @type {string } */ xmlName ;
18231830 if ( ! name ) {
18241831 name = /** @type {string } */ ( this . _getValue (
@@ -1832,11 +1839,23 @@ export class ExampleGenerator extends AmfHelperMixin(Object) {
18321839 if ( name . indexOf ( '?' ) !== - 1 ) {
18331840 name = name . replace ( '?' , '' ) ;
18341841 }
1835- let value = this . _readDataType ( range ) ;
1836- if ( ! value ) {
1837- value = '' ;
1842+ let exampleValue ;
1843+ if ( example ) {
1844+ const sKey = this . _getAmfKey (
1845+ this . ns . aml . vocabularies . document . structuredValue
1846+ ) ;
1847+ const structure = example [ sKey ] ;
1848+ exampleValue = this . _computeStructuredExampleValue ( structure [ 0 ] ) ;
1849+ }
1850+ if ( exampleValue ) {
1851+ node . setAttribute ( name , String ( exampleValue ) ) ;
1852+ } else {
1853+ let value = this . _readDataType ( range ) ;
1854+ if ( ! value ) {
1855+ value = '' ;
1856+ }
1857+ node . setAttribute ( name , value ) ;
18381858 }
1839- node . setAttribute ( name , value ) ;
18401859 }
18411860
18421861 /**
0 commit comments