IfcType.xsl 3.66 KB
Newer Older
1
<?xml version="1.0" encoding="utf-8"?>
2
<!-- KIT Tool | EneffBIM converter 2016  Version 0.5 (Author KIT BLM) IfcType.xsl 1.8.2016 --><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://d-alchemy.com/schema/simxml/Model" xmlns:simcore="http://d-alchemy.com/schema/simxml/SimModelCore" xmlns:simres="http://d-alchemy.com/schema/simxml/ResourcesGeneral" xmlns:simgeom="http://d-alchemy.com/schema/simxml/ResourcesGeometry" xmlns:simbldg="http://d-alchemy.com/schema/simxml/BuildingModel" xmlns:simmep="http://d-alchemy.com/schema/simxml/MepModel" xmlns:ifc="http://www.buildingsmart-tech.org/ifcXML/IFC4/Add1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.buildingsmart-tech.org/ifcXML/IFC4/final ../../../../../../EnEffBIM_UseCases/IFCSchema/IFC4_ADD1.xsd" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="xsl ifc msxsl">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/>
	<xsl:strip-space elements="*"/>
	<xsl:template name="IfcType">
		<xsl:param name="returnTypeObject"/>
		<xsl:for-each select=".">
			<xsl:variable name="resolveType">
				<xsl:call-template name="ResolveIfcRelDefinesByType">
				</xsl:call-template>
			</xsl:variable>
			<xsl:variable name="typeTag">
				<xsl:value-of select="@ObjectType"/>
			</xsl:variable>
			<xsl:variable name="occuranceName">
				<xsl:value-of select="name()"/>
			</xsl:variable>
			<xsl:variable name="IterateIfcTypes">
				<xsl:for-each select="msxsl:node-set($resolveType)/node()">
					<xsl:choose>
						<xsl:when test="current()/ifc:HasPropertySets">
							<xsl:choose>
								<xsl:when test="$returnTypeObject != ''">
									<xsl:value-of select="current()/@PredefinedType"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:for-each select="current()/ifc:HasPropertySets/ifc:IfcPropertySet">
										<xsl:copy-of select="current()"/>
									</xsl:for-each>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise>
							<xsl:for-each select="msxsl:node-set($allsourceobjects)/node()">
								<xsl:if test="current()[@id = $resolveType]">
									<xsl:choose>
										<xsl:when test="$returnTypeObject != ''">
											<xsl:value-of select="@PredefinedType"/>
										</xsl:when>
										<xsl:otherwise>
											<xsl:for-each select="current()/ifc:HasPropertySets/ifc:IfcPropertySet">
												<xsl:copy-of select="current()"/>
											</xsl:for-each>
										</xsl:otherwise>
									</xsl:choose>
								</xsl:if>
							</xsl:for-each>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:for-each>
			</xsl:variable>
			<xsl:choose>
				<xsl:when test="$resolveType != ''">
					<xsl:copy-of select="$IterateIfcTypes"/>
				</xsl:when>
				<xsl:when test="$typeTag != ''">
					<xsl:copy-of select="$IterateIfcTypes"/>
				</xsl:when>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="ResolveIfcRelDefinesByType">
		<xsl:variable name="elemid">
			<xsl:copy>
				<xsl:value-of select="@id"/>
			</xsl:copy>
		</xsl:variable>
		<xsl:if test="$elemid != ''">
			<xsl:for-each select="msxsl:node-set($allsourceobjects)/ifc:IfcRelDefinesByType/ifc:RelatedObjects/node()">
				<xsl:if test="current()[contains(@ref, $elemid)] | current()[contains(@href, $elemid)]">
					<xsl:choose>
						<xsl:when test="../../ifc:RelatingType[@GlobalId] != ''">
							<xsl:copy-of select="../../ifc:RelatingType"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="../../ifc:RelatingType/@ref | ../../ifc:RelatingType/@href"/>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:if>
			</xsl:for-each>
		</xsl:if>
	</xsl:template></xsl:stylesheet>