GenerateTargetElement.xsl 8.39 KB
Newer Older
1
<?xml version="1.0" encoding="utf-8"?>
2
<!-- KIT Tool | EneffBIM converter 2016  Version 0.5 (Author KIT BLM) GenerateTargetElement.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: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="GenerateTargetElement">
		<xsl:param name="KeyPool"/>
		<xsl:param name="simelemname"/>
		<xsl:param name="unsortedtargetcontent"/>
		<xsl:if test="current()[@GlobalId]">
			<xsl:for-each select=".">
				<xsl:element name="{$simelemname}">
					<xsl:attribute name="RefId"><xsl:call-template name="TargetValueFormatConditions"><xsl:with-param name="sourcename"><xsl:value-of select="'GlobalId'"/></xsl:with-param><xsl:with-param name="sourcevalue"><xsl:value-of select="@GlobalId"/></xsl:with-param></xsl:call-template></xsl:attribute>
					<xsl:call-template name="IterateAlongSequenceOrder">
						<xsl:with-param name="KeyPool" select="$KeyPool"/>
						<xsl:with-param name="CurrentSimElementName" select="$simelemname"/>
						<xsl:with-param name="unsortedtargetcontent" select="$unsortedtargetcontent"/>
					</xsl:call-template>
				</xsl:element>
			</xsl:for-each>
		</xsl:if>
	</xsl:template>
	<xsl:template name="GenerateTargetElementContentsFromSourceProperties">
		<xsl:param name="KeyPool"/>
		<xsl:param name="preEvaluation"/>
		<xsl:variable name="elementId" select="@GlobalId"/>
		<xsl:if test="current()[@GlobalId]">
			<xsl:for-each select=".">
				<xsl:variable name="PropertySetsByType">
					<xsl:call-template name="IfcType">
					</xsl:call-template>
				</xsl:variable>
				<xsl:variable name="PropertySetsByRelDefBy">
					<xsl:call-template name="ResolveIfcRelDefinesByProperties">
					</xsl:call-template>
					<xsl:if test="current()/IsDefinedBy">
						<xsl:for-each select="current()/IsDefinedBy/IfcRelDefinesByProperties/RelatingPropertyDefinition">
							<xsl:copy-of select="current()"/>
						</xsl:for-each>
					</xsl:if>
				</xsl:variable>
				<xsl:variable name="ConcatedPsetCollections">
					<xsl:call-template name="DuplicateFilterSourceObjectPropertyCollectionMerge">
						<xsl:with-param name="firstCollection" select="$PropertySetsByRelDefBy"/>
						<xsl:with-param name="secondCollection" select="$PropertySetsByType"/>
					</xsl:call-template>
				</xsl:variable>
				<xsl:for-each select="msxsl:node-set($ConcatedPsetCollections)/*">
					<xsl:call-template name="IfcPropertySet">
						<xsl:with-param name="KeyPool" select="$KeyPool"/>
						<xsl:with-param name="preEvaluation" select="$preEvaluation"/>
						<xsl:with-param name="elementId" select="$elementId"/>
					</xsl:call-template>
				</xsl:for-each>
			</xsl:for-each>
		</xsl:if>
	</xsl:template>
	<xsl:template name="MergeTargetElementContentCollections">
		<xsl:param name="generictargetcontent"/>
		<xsl:param name="resolvedfromproperties"/>
		<xsl:for-each select="msxsl:node-set($generictargetcontent)/node()">
			<xsl:variable name="psetitem" select="local-name()"/>
			<xsl:variable name="check_pset_pregem">
				<xsl:for-each select="msxsl:node-set($resolvedfromproperties)/node()">
					<xsl:if test="local-name() = $psetitem">
						<xsl:copy-of select="current()"/>
					</xsl:if>
				</xsl:for-each>
			</xsl:variable>
			<xsl:choose>
				<xsl:when test="$check_pset_pregem != ''">
					<xsl:copy-of select="$check_pset_pregem"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:copy-of select="current()"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="filterAllElementContents">
		<xsl:param name="input"/>
		<xsl:for-each select="msxsl:node-set($input)/node()">
			<xsl:if test="not(starts-with(local-name(), 'eeBIMc_FLAG_')) or not(starts-with(local-name(), 'eeBIMprv01_FLAG_')) or not(starts-with(local-name(), 'eeBIMprv02_FLAG_')) or not(starts-with(local-name(), 'eeBIMprv03_FLAG_'))">
				<xsl:copy-of select="current()"/>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="filterAllOtherContents">
		<xsl:param name="input"/>
		<xsl:param name="token"/>
		<xsl:variable name="filter">
			<xsl:for-each select="msxsl:node-set($input)/node()">
				<xsl:if test="starts-with(local-name(), $token)">
					<xsl:copy-of select="current()"/>
				</xsl:if>
			</xsl:for-each>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="msxsl:node-set($filter)/node()">
				<xsl:copy-of select="$filter"/>
			</xsl:when>
			<xsl:otherwise>FALSE</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="FillSceleton">
		<xsl:param name="taggedTargetContent"/>
		<xsl:param name="prefixToken"/>
		<xsl:for-each select="msxsl:node-set($taggedTargetContent)/node()">
			<xsl:variable name="designatedElementTargetName">
				<xsl:value-of select="substring-before(text(), ' ' )"/>
			</xsl:variable>
			<xsl:choose>
				<xsl:when test="contains(name(), 'eeBIMc_FLAG_SimDummy')">
					<xsl:element name="{normalize-space($designatedElementTargetName)}">
						<xsl:attribute name="RefId"><xsl:value-of select="normalize-space(substring-after(text(), ' ' ))"/></xsl:attribute>
						<xsl:for-each select="msxsl:node-set($taggedTargetContent)/node()">
							<xsl:if test="not(contains(name(), 'SimDummy')) and normalize-space(substring-after(local-name(),$prefixToken)) != '' and substring-before(text(), ' ') != ''">
								<xsl:element name="{normalize-space(substring-before(text(), ' '))}">
									<xsl:value-of select="substring-after(text(), ' ')"/>
								</xsl:element>
							</xsl:if>
						</xsl:for-each>
					</xsl:element>
				</xsl:when>
				<xsl:when test="contains(name(), 'SimDummy')">
					<xsl:element name="{normalize-space($designatedElementTargetName)}">
						<xsl:attribute name="RefId"><xsl:value-of select="normalize-space(substring-after(text(), ' ' ))"/></xsl:attribute>
						<xsl:variable name="content">
							<xsl:for-each select="msxsl:node-set($taggedTargetContent)/node()">
								<xsl:if test="not(contains(name(), 'SimDummy')) and normalize-space(substring-after(local-name(),$prefixToken)) != '' and substring-before(text(), ' ') != ''">
									<xsl:variable name="simelemname" select="normalize-space(substring-before(text(), ' '))"/>
									<xsl:element name="{$simelemname}">
										<xsl:choose>
											<xsl:when test="contains(substring-after(text(), ' '),'__')">
												<xsl:call-template name="resolve_valtype_val_list">
													<xsl:with-param name="list" select="substring-after(text(), ' ')"/>
												</xsl:call-template>
											</xsl:when>
											<xsl:otherwise>
												<xsl:value-of select="substring-after(text(), ' ')"/>
											</xsl:otherwise>
										</xsl:choose>
									</xsl:element>
								</xsl:if>
							</xsl:for-each>
						</xsl:variable>
						<xsl:call-template name="IterateAlongSequenceOrder">
							<xsl:with-param name="CurrentSimElementName" select="$designatedElementTargetName"/>
							<xsl:with-param name="unsortedtargetcontent" select="$content"/>
						</xsl:call-template>
					</xsl:element>
				</xsl:when>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="resolve_valtype_val_list">
		<xsl:param name="list"/>
		<xsl:choose>
			<xsl:when test="not(contains(substring-after(substring-after($list,'__'),'__'),'__'))">
				<xsl:element name="{substring-before(substring-after($list,'__'),'__')}">
					<xsl:value-of select="substring-after(substring-after($list,'__'),'__')"/>
				</xsl:element>
			</xsl:when>
			<xsl:when test="contains(substring-after(substring-after($list,'__'),'__'),'__')">
				<xsl:element name="{substring-before(substring-after($list,'__'),'__')}">
					<xsl:value-of select="substring-before(substring-after(substring-after($list,'__'),'__'),'__')"/>
				</xsl:element>
				<xsl:call-template name="resolve_valtype_val_list">
					<xsl:with-param name="list" select="substring-after(substring-after($list,'__'),'__')"/>
				</xsl:call-template>
			</xsl:when>
		</xsl:choose>
	</xsl:template></xsl:stylesheet>