Skip to content

Commit cb9848a

Browse files
committed
fix(core): incorrect ids export
1 parent dd9f0d4 commit cb9848a

File tree

8 files changed

+80
-37
lines changed

8 files changed

+80
-37
lines changed

packages/core/src/openbim/IDSSpecifications/index.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -196,22 +196,22 @@ export class IDSSpecifications extends Component {
196196
specifications: Iterable<IDSSpecification> = this.list.values(),
197197
) {
198198
const _specifications = specifications ?? this.list;
199-
const xml = `<ids:ids xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://standards.buildingsmart.org/IDS http://standards.buildingsmart.org/IDS/1.0/ids.xsd" xmlns:ids="http://standards.buildingsmart.org/IDS">
199+
const xml = `<ids xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://standards.buildingsmart.org/IDS http://standards.buildingsmart.org/IDS/1.0/ids.xsd" xmlns:ids="http://standards.buildingsmart.org/IDS">
200200
<!-- Made with That Open Engine ${Components.release} (https://github.com/thatopen/engine_components) -->
201-
<ids:info>
202-
<ids:title>${info.title}</ids:title>
203-
${info.copyright ? `<ids:copyright>${info.copyright}</ids:copyright>` : ""}
204-
${info.version ? `<ids:version>${info.version}</ids:version>` : ""}
205-
${info.description ? `<ids:description>${info.description}</ids:description>` : ""}
206-
${info.author ? `<ids:author>${info.author}</ids:author>` : ""}
207-
${info.date ? `<ids:date>${info.date.toISOString().split("T")[0]}</ids:date>` : ""}
208-
${info.purpose ? `<ids:purpose>${info.purpose}</ids:purpose>` : ""}
209-
${info.milestone ? `<ids:milestone>${info.milestone}</ids:milestone>` : ""}
210-
</ids:info>
211-
<ids:specifications>
201+
<info>
202+
<title>${info.title}</title>
203+
${info.copyright ? `<copyright>${info.copyright}</copyright>` : ""}
204+
${info.version ? `<version>${info.version}</version>` : ""}
205+
${info.description ? `<description>${info.description}</description>` : ""}
206+
${info.author ? `<author>${info.author}</author>` : ""}
207+
${info.date ? `<date>${info.date.toISOString().split("T")[0]}</date>` : ""}
208+
${info.purpose ? `<purpose>${info.purpose}</purpose>` : ""}
209+
${info.milestone ? `<milestone>${info.milestone}</milestone>` : ""}
210+
</info>
211+
<specifications>
212212
${[..._specifications].map((spec) => spec.serialize()).join("\n")}
213-
</ids:specifications>
214-
</ids:ids>`;
213+
</specifications>
214+
</ids>`;
215215

216216
return xml;
217217
}

packages/core/src/openbim/IDSSpecifications/src/Specification.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ export class IDSSpecification implements IDSSpecificationData {
113113
? `instructions="${this.instructions}"`
114114
: "";
115115

116-
const xml = `<ids:specification ifcVersion="${[...this.ifcVersion].join(" ")}" ${name} ${identifier} ${description} ${instructions}>
117-
<ids:applicability minOccurs="1" maxOccurs="unbounded">
118-
${[...this.applicability].map((facet) => facet.serialize("applicability"))}
119-
</ids:applicability>
120-
<ids:requirements>
121-
${[...this.requirements].map((facet) => facet.serialize("requirement"))}
122-
</ids:requirements>
123-
</ids:specification>`;
116+
const xml = `<specification ifcVersion="${[...this.ifcVersion].join(" ")}" ${name} ${identifier} ${description} ${instructions}>
117+
<applicability minOccurs="1" maxOccurs="unbounded">
118+
${[...this.applicability].map((facet) => facet.serialize("applicability")).join("\n")}
119+
</applicability>
120+
<requirements>
121+
${[...this.requirements].map((facet) => facet.serialize("requirement")).join("\n")}
122+
</requirements>
123+
</specification>`;
124124
return xml;
125125
}
126126
}

packages/core/src/openbim/IDSSpecifications/src/exporters/parameter.ts

+47-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ export const getParameterXML = (
66
) => {
77
let parameterXML = "";
88
if (!parameter) return parameterXML;
9+
910
if (parameter.type === "simple") {
10-
parameterXML = `<ids:simpleValue>${parameter.parameter}</ids:simpleValue>`;
11+
parameterXML = `<simpleValue>${parameter.parameter}</simpleValue>`;
1112
}
1213

1314
if (parameter.type === "enumeration") {
1415
const value = parameter.parameter;
1516
parameterXML = `<xs:restriction base="xs:string">
16-
${value.map((v) => `<xs:enumeration value="${v}" />`).join("\r\n")}
17+
${value.map((v) => `<xs:enumeration value="${v}" />`).join("\n")}
1718
</xs:restriction>`;
1819
}
1920

@@ -24,9 +25,51 @@ export const getParameterXML = (
2425
</xs:restriction>`;
2526
}
2627

27-
const xml = `<ids:${name[0].toLowerCase() + name.slice(1)}>
28+
if (parameter.type === "bounds") {
29+
const { min, minInclusive, max, maxInclusive } = parameter.parameter;
30+
let minTag = "";
31+
if (min !== undefined) {
32+
minTag = `<xs:min${minInclusive ? "Inclusive" : "Exclusive"} value="${min}">`;
33+
}
34+
35+
let maxTag = "";
36+
if (max !== undefined) {
37+
maxTag = `<xs:max${maxInclusive ? "Inclusive" : "Exclusive"} value="${max}">`;
38+
}
39+
40+
parameterXML = `<xs:restriction base="xs:double">
41+
${minTag}
42+
${maxTag}
43+
</xs:restriction>`;
44+
}
45+
46+
if (parameter.type === "length") {
47+
const { length, min, max } = parameter.parameter;
48+
let lengthTag = "";
49+
if (length !== undefined && min === undefined && max === undefined) {
50+
lengthTag = `<xs:length value="${length}" />`;
51+
}
52+
53+
let minTag = "";
54+
if (min !== undefined && length === undefined) {
55+
minTag = `<xs:minLength value="${min}" />`;
56+
}
57+
58+
let maxTag = "";
59+
if (max !== undefined && length === undefined) {
60+
maxTag = `<xs:maxLength value="${max}" />`;
61+
}
62+
63+
parameterXML = `<xs:restriction base="xs:string">
64+
${lengthTag}
65+
${minTag}
66+
${maxTag}
67+
</xs:restriction>`;
68+
}
69+
70+
const xml = `<${name[0].toLowerCase() + name.slice(1)}>
2871
${parameterXML}
29-
</ids:${name[0].toLowerCase() + name.slice(1)}>`;
72+
</${name[0].toLowerCase() + name.slice(1)}>`;
3073

3174
return xml;
3275
};

packages/core/src/openbim/IDSSpecifications/src/facets/Attribute.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ export class IDSAttribute extends IDSFacet {
2626
? `instructions="${this.instructions}"`
2727
: "";
2828
}
29-
return `<ids:attribute ${attributes}>
29+
return `<attribute ${attributes}>
3030
${nameXML}
3131
${valueXML}
32-
</ids:attribute>`;
32+
</attribute>`;
3333
}
3434

3535
// This can be very ineficcient as we do not have an easy way to get an entity based on an attribute

packages/core/src/openbim/IDSSpecifications/src/facets/Classification.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ export class IDSClassification extends IDSFacet {
3030
? `instructions="${this.instructions}"`
3131
: "";
3232
}
33-
return `<ids:classification ${attributes}>
33+
return `<classification ${attributes}>
3434
${systemXML}
3535
${valueXML}
36-
</ids:classification>`;
36+
</classification>`;
3737
}
3838

3939
async getEntities(

packages/core/src/openbim/IDSSpecifications/src/facets/Entity.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ export class IDSEntity extends IDSFacet {
2727
? `instructions="${this.instructions}"`
2828
: "";
2929
}
30-
return `<ids:entity ${attributes}>
30+
return `<entity ${attributes}>
3131
${nameXML}
3232
${predefinedTypeXML}
33-
</ids:entity>`;
33+
</entity>`;
3434
}
3535

3636
// IFCSURFACESTYLEREFRACTION is not present in the FragmentsGroup

packages/core/src/openbim/IDSSpecifications/src/facets/Material.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class IdsMaterialFacet extends IDSFacet {
1010
uri?: string;
1111

1212
serialize(type: "applicability" | "requirement") {
13-
if (!(this.value && this.uri)) return "<ids:material />";
13+
if (!(this.value && this.uri)) return "<material />";
1414
const valueXML = getParameterXML("Value", this.value);
1515
let attributes = "";
1616
if (type === "requirement") {
@@ -20,9 +20,9 @@ export class IdsMaterialFacet extends IDSFacet {
2020
? `instructions="${this.instructions}"`
2121
: "";
2222
}
23-
return `<ids:material ${attributes}>
23+
return `<material ${attributes}>
2424
${valueXML}
25-
</ids:material>`;
25+
</material>`;
2626
}
2727

2828
async getEntities() {

packages/core/src/openbim/IDSSpecifications/src/facets/Property.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ export class IDSProperty extends IDSFacet {
4545
? `instructions="${this.instructions}"`
4646
: "";
4747
}
48-
return `<ids:property ${dataTypeXML} ${attributes}>
48+
return `<property ${dataTypeXML} ${attributes}>
4949
${propertySetXML}
5050
${baseNameXML}
5151
${valueXML}
52-
</ids:property>`;
52+
</property>`;
5353
}
5454

5555
async getEntities(

0 commit comments

Comments
 (0)