basyx-typescript-sdk 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -441,3 +441,53 @@ const endpoint = extractEndpointHref(descriptor, 'AAS-3.0');
441
441
  const encoded = base64Encode('https://example.com/ids/aas/my-aas');
442
442
  // Use in URL: http://localhost:8081/shells/{encoded}
443
443
  ```
444
+
445
+ ### XML Serialization and Deserialization
446
+
447
+ ```typescript
448
+ import { serializeXml, deserializeXml } from 'basyx-typescript-sdk';
449
+ import { BaSyxEnvironment } from 'basyx-typescript-sdk';
450
+ import { AssetAdministrationShell, AssetInformation, AssetKind, Submodel, ModellingKind } from '@aas-core-works/aas-core3.0-typescript/types';
451
+
452
+ // Create an environment with AAS and Submodels
453
+ const environment = new BaSyxEnvironment(
454
+ [
455
+ new AssetAdministrationShell(
456
+ 'https://example.com/ids/aas/my-aas',
457
+ new AssetInformation(AssetKind.Instance)
458
+ )
459
+ ],
460
+ [
461
+ new Submodel(
462
+ 'https://example.com/ids/sm/my-submodel',
463
+ null,
464
+ null,
465
+ 'MySubmodel',
466
+ null,
467
+ null,
468
+ null,
469
+ ModellingKind.Instance
470
+ )
471
+ ],
472
+ [] // conceptDescriptions
473
+ );
474
+
475
+ // Serialize to XML string
476
+ const xmlString = serializeXml(environment);
477
+ console.log(xmlString);
478
+ // Output:
479
+ // <?xml version="1.0" encoding="UTF-8"?>
480
+ // <aas:environment xmlns:aas="https://admin-shell.io/aas/3/1"
481
+ // xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
482
+ // xsi:schemaLocation="https://admin-shell.io/aas/3/1 AAS.xsd">
483
+ // ...
484
+ // </aas:environment>
485
+
486
+ // Customize namespace prefix (default is 'aas')
487
+ const xmlWithCustomPrefix = serializeXml(environment, 'custom');
488
+
489
+ // Deserialize XML back to BaSyxEnvironment
490
+ const deserializedEnv = deserializeXml(xmlString);
491
+ console.log('AAS:', deserializedEnv.assetAdministrationShells);
492
+ console.log('Submodels:', deserializedEnv.submodels);
493
+ ```
@@ -0,0 +1 @@
1
+ export { deserializeXml, serializeXml } from './xmlization';
@@ -0,0 +1 @@
1
+ export { deserializeXml, serializeXml } from './xmlization';
@@ -0,0 +1,3 @@
1
+ import { BaSyxEnvironment } from '../../models/BaSyxEnvironment';
2
+ export declare function serializeXml(data: BaSyxEnvironment, namespacePrefix?: string): string;
3
+ export declare function deserializeXml(xmlString: string): BaSyxEnvironment;