<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet
    xmlns:ASFALIS2006="http://www.elysium.co.jp/2006/ASFALIS-NS/"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="5.0">


    <xsl:output method="html"/>

<!-- ########################### ASFALIS2006 ############################## -->
<!-- ###################################################################### -->
<!-- Root of this style sheet -->
    <xsl:template match="/ASFALIS2006:AsfalisLogList">
        <HTML>
        <HEAD>
            <TITLE>3DxSUITE Log File</TITLE>
        </HEAD>

        <BODY>
        <H1>3DxSUITE Execution Log</H1>
        <xsl:for-each select="ASFALIS2006:AsfalisLog">
            <xsl:choose>
                <xsl:when test="@type='CAD2ENF'"><H1>Importer</H1></xsl:when>
                <xsl:when test="@type='ENF2CAD'"><H1>Exporter</H1></xsl:when>
                <xsl:when test="@type='AUTOHEAL'"><H1>Geometry Healer</H1></xsl:when>
                <xsl:when test="@type='PDQCHECK'"><H1>PDQ Checker</H1></xsl:when>
                <xsl:when test="@type='ELYBATCH'"><H1>Elybatch</H1></xsl:when>
                <xsl:when test="@type='SIMPLIFY'"><H1>Geometry Simplifier</H1></xsl:when>
                <xsl:when test="@type='GEOMDIFF'"><H1>CAD Validator</H1></xsl:when>
                <xsl:when test="@type='PLYGNOPTIMIZE'"><H1>Polygon Optimizer</H1></xsl:when>
                <xsl:when test="@type='POLYGON'"><H1>Polygon Creator</H1></xsl:when>
                <xsl:when test="@type='ENFEDITOR'"><H1>ENF Editor</H1></xsl:when>
                <xsl:when test="@type='MIDSURFACE'"><H1>Mid Surfacer</H1></xsl:when>
                <xsl:when test="@type='REVERSE'"><H1>Reverse Engineer</H1></xsl:when>
                <xsl:otherwise><H1>Unknown component</H1></xsl:otherwise>
            </xsl:choose>

            <xsl:if test="@isPrimary='no'">
                (Additional Information)
            </xsl:if>

            <xsl:apply-templates select="ASFALIS2006:ProcessInfo"/>
            <xsl:apply-templates select="ASFALIS2006:ModelInfoList"/>
            <xsl:apply-templates select="ASFALIS2006:AssemblyTreeInfo"/>
            <xsl:apply-templates select="ASFALIS2006:BodyInfoList"/>
            <xsl:apply-templates select="ASFALIS2006:ComponentInfoList"/>
            <xsl:call-template name="ASFALIS2006:PrintGeometryValidation"/>
            <HR/>
        </xsl:for-each>
        </BODY>
        </HTML>
    </xsl:template>



<!-- ###################################################################### -->

<!--
    Print information of overall process
  -->
    <xsl:template match="ASFALIS2006:ProcessInfo">
        <H2>Summary</H2>
        <TABLE border="1">
            <TR>
                <TH>OriginalCAD</TH>
                <TD><xsl:value-of select="ASFALIS2006:OriginalCad/@name"/></TD>
                <TD><xsl:value-of select="ASFALIS2006:OriginalCad/@version"/></TD>
            </TR>
            <TR>
                <TH>TargetCAD</TH>
                <TD><xsl:value-of select="ASFALIS2006:TargetCad/@name"/></TD>
                <TD><xsl:value-of select="ASFALIS2006:TargetCad/@version"/></TD>
            </TR>
            <TR>
                <TH>InputFileName</TH>
                <TD><xsl:value-of select="ASFALIS2006:InputFile/@fileName"/></TD>
                <TD><xsl:value-of select="ASFALIS2006:InputFile/@version"/></TD>
            </TR>
            <TR>
                <TH>OutputFileName</TH>
                <TD><xsl:value-of select="ASFALIS2006:OutputFile/@fileName"/></TD>
                <TD><xsl:value-of select="ASFALIS2006:OutputFile/@version"/></TD>
            </TR>
            <TR>
                <TH>StartTime</TH>
                <TD colspan="2"><xsl:value-of select="ASFALIS2006:TimeInfo/@startTime"/></TD>
            </TR>
            <TR>
                <TH>EndTime</TH>
                <TD colspan="2"><xsl:value-of select="ASFALIS2006:TimeInfo/@endTime"/></TD>
            </TR>
            <TR>
                <TH>Duration</TH>
                <TD colspan="2"><xsl:value-of select="ASFALIS2006:TimeInfo/@duration"/></TD>
            </TR>
            <TR>
                <TH>Module</TH>
                <TD><xsl:value-of select="ASFALIS2006:ElysiumModule/@fileName"/></TD>
                <TD><xsl:value-of select="ASFALIS2006:ElysiumModule/@version"/></TD>
            </TR>
        </TABLE>

        <xsl:apply-templates select="ASFALIS2006:Errors"/>
        <xsl:call-template name="ASFALIS2006:ProcessDetailInfo"/>
    </xsl:template>

<!-- ###################################################################### -->
<!--
    Print information of model, (occurrence tree)
  -->
    <xsl:template match="ASFALIS2006:ModelInfoList">
        <HR/>
        <H2>Assembly Tree</H2>
            <xsl:for-each select="ASFALIS2006:ModelInfo">
                <xsl:call-template name="ASFALIS2006:PrintModelInfo"/>
                <HR/>
            </xsl:for-each>
    </xsl:template>

    <xsl:template name="ASFALIS2006:PrintModelInfo">
        <xsl:for-each select="ASFALIS2006:ComponentRef">
            <xsl:call-template name="ASFALIS2006:PrintComponentRef"/>
        </xsl:for-each>
    </xsl:template>

    <xsl:template name="ASFALIS2006:PrintComponentRef">
        <xsl:for-each select="@dekId">
            [ID : <xsl:value-of select="."/>]  
        </xsl:for-each>
        <UL>
        <xsl:for-each select="ASFALIS2006:ComponentInstanceInfo">
            <LI><xsl:call-template name="ASFALIS2006:PrintComponentInstanceInfo"/></LI>
        </xsl:for-each>
        </UL>
    </xsl:template>

    <xsl:template name="ASFALIS2006:PrintComponentInstanceInfo">
        <xsl:for-each select="@instanceName">
            [<xsl:value-of select="."/>]  
        </xsl:for-each>
        <xsl:for-each select="ASFALIS2006:ComponentRef">
            <xsl:call-template name="ASFALIS2006:PrintComponentRef"/>
        </xsl:for-each>
     </xsl:template>


<!-- ###################################################################### -->
<!--
    Print information of assembly tree
  -->
    <xsl:template match="ASFALIS2006:AssemblyTreeInfo">
        <HR/>
        <H2>Assembly Tree</H2>
        <UL>
        <xsl:for-each select="ASFALIS2006:AssemblyInfo">
            <LI><xsl:call-template name="ASFALIS2006:PrintAssemblyInfo"/></LI>
        </xsl:for-each>
        <xsl:for-each select="ASFALIS2006:BodyRef">
            <LI><xsl:call-template name="ASFALIS2006:PrintBodyRefInfo"/></LI>
        </xsl:for-each>
        </UL>
    </xsl:template>

<!--
    Print information of assembly
  -->
    <xsl:template name="ASFALIS2006:PrintAssemblyInfo">
        A  
        <xsl:for-each select="@assemblyName">
            [<xsl:value-of select="."/>]  
        </xsl:for-each>

        <xsl:for-each select="@assemblyDekId">
            [ID : <xsl:value-of select="."/>]  
        </xsl:for-each>

        <xsl:for-each select="@assemblyPartNumber">
            [Part Number = <xsl:value-of select="."/>]
        </xsl:for-each>
        <BR/>
        <UL>
            <xsl:for-each select="ASFALIS2006:InstanceInfo">
                <LI>
                    <xsl:call-template name="ASFALIS2006:PrintInstanceInfo"/>
                </LI>
            </xsl:for-each>
        </UL>
    </xsl:template>


<!--
    Print information of assembly instance
  -->
    <xsl:template name="ASFALIS2006:PrintInstanceInfo">
        I   
        <xsl:for-each select="@instanceName">
            [<xsl:value-of select="."/>]  
        </xsl:for-each>
        <xsl:for-each select="@instanceDekId">
            [ID : <xsl:value-of select="."/>]  
        </xsl:for-each>
        <BR/>
        <UL>
        <xsl:for-each select="ASFALIS2006:AssemblyInfo">
            <LI><xsl:call-template name="ASFALIS2006:PrintAssemblyInfo"/></LI>
        </xsl:for-each>
        <xsl:for-each select="ASFALIS2006:BodyRef">
            <LI><xsl:call-template name="ASFALIS2006:PrintBodyRefInfo"/></LI>
        </xsl:for-each>
        </UL>
     </xsl:template>


<!--
    Print information of body reference from assembly tree
  -->
    <xsl:template name="ASFALIS2006:PrintBodyRefInfo">
        B 
        <xsl:for-each select="@bodyName">
            [<xsl:value-of select="."/>]  
        </xsl:for-each>

        <xsl:for-each select="@bodyDekId">
            [ID : <xsl:value-of select="."/>]  
        </xsl:for-each>
    </xsl:template>


<!-- ###################################################################### -->
<!--
    Print information of each component
  -->
    <xsl:template match="ASFALIS2006:ComponentInfoList">
        <HR/>
        <H2>Information about each Component (Part or Assembly)</H2>
            <xsl:for-each select="ASFALIS2006:ComponentInfo">
                <xsl:call-template name="ASFALIS2006:PrintComponentInfo"/>
                <HR/>
            </xsl:for-each>
    </xsl:template>

    <xsl:template name="ASFALIS2006:PrintComponentInfo">
        <TABLE border="1">
            <xsl:for-each select="@dekId">
                <TR>
                    <TH>Part ID (ENF)</TH><TH><xsl:value-of select="."/></TH>
                </TR>
            </xsl:for-each>

            <xsl:for-each select="@componentType">
                <TR>
                    <TH>Type</TH><TH><xsl:value-of select="."/></TH>
                </TR>
            </xsl:for-each>

            <xsl:for-each select="@componentName">
                <TR>
                    <TH>Name</TH><TH><xsl:value-of select="."/></TH>
                </TR>
            </xsl:for-each>

            <xsl:for-each select="@partName">
                <TR>
                    <TH>Part Name</TH><TD><xsl:value-of select="."/></TD>
                </TR>
            </xsl:for-each>

            <xsl:for-each select="@partNumber">
                <TR>
                    <TH>Part Number</TH><TD><xsl:value-of select="."/></TD>
                </TR>
            </xsl:for-each>
            
            <xsl:for-each select="@nativeFilename">
                <TR>
                    <TH>Original CAD file name</TH><TD><xsl:value-of select="."/></TD>
                </TR>
            </xsl:for-each>

        </TABLE>

        <xsl:for-each select="ASFALIS2006:Representation">
            <xsl:call-template name="ASFALIS2006:PrintRepresentation"/>
        </xsl:for-each>
        
    </xsl:template>


    <xsl:template name="ASFALIS2006:PrintRepresentation">
        <xsl:for-each select="ASFALIS2006:Errors">
            <xsl:call-template name="ASFALIS2006:PrintErrors"/>
        </xsl:for-each>

        <xsl:for-each select="ASFALIS2006:MassProperties">
            <xsl:call-template name="ASFALIS2006:PrintMassProperties"/>
        </xsl:for-each>

        <xsl:for-each select="ASFALIS2006:EntityNumberSets">
            <xsl:call-template name="ASFALIS2006:PrintEntityNumberSets"/>
        </xsl:for-each>
    </xsl:template>

<!--
    Print information of each body
  -->
    <xsl:template match="ASFALIS2006:BodyInfoList">
        <HR/>
        <H2>Information about each Body (Part)</H2>
            <xsl:for-each select="ASFALIS2006:BodyInfo">
                <xsl:call-template name="ASFALIS2006:PrintBodyInfo"/>
                <HR/>
            </xsl:for-each>
    </xsl:template>

    <xsl:template name="ASFALIS2006:PrintBodyInfo">
        <TABLE border="1">
            <xsl:for-each select="@bodyDekId">
                <TR>
                    <TH>Part ID (ENF)</TH><TH><xsl:value-of select="."/></TH>
                </TR>
            </xsl:for-each>

            <xsl:for-each select="@bodyName">
                <TR>
                    <TH>Name</TH><TH><xsl:value-of select="."/></TH>
                </TR>
            </xsl:for-each>

            <xsl:for-each select="@partName">
                <TR>
                    <TH>Part Name</TH><TD><xsl:value-of select="."/></TD>
                </TR>
            </xsl:for-each>

            <xsl:for-each select="@partNumber">
                <TR>
                    <TH>Part Number</TH><TD><xsl:value-of select="."/></TD>
                </TR>
            </xsl:for-each>

            <xsl:for-each select="@nativeFilename">
                <TR>
                    <TH>Original CAD file name</TH><TD><xsl:value-of select="."/></TD>
                </TR>
            </xsl:for-each>
        </TABLE>

        <xsl:for-each select="ASFALIS2006:Errors">
            <xsl:call-template name="ASFALIS2006:PrintErrors"/>
        </xsl:for-each>

        <xsl:for-each select="ASFALIS2006:MassProperties">
            <xsl:call-template name="ASFALIS2006:PrintMassProperties"/>
        </xsl:for-each>

        <xsl:for-each select="ASFALIS2006:EntityNumberSets">
            <xsl:call-template name="ASFALIS2006:PrintEntityNumberSets"/>
        </xsl:for-each>
    </xsl:template>


<!-- ###################################################################### -->
    <!--
        Print error information
      -->
    <xsl:template match="ASFALIS2006:Errors">
        <xsl:call-template name="ASFALIS2006:PrintErrors"/>
    </xsl:template>

    <xsl:template name="ASFALIS2006:PrintErrors">
        <H4><FONT color="#FF0000">Translation error</FONT></H4>
        <TABLE border="1">
            <TR>
                <TH>Translation error type</TH>
                <TH>Description</TH>
            </TR>
            <xsl:for-each select="ASFALIS2006:Error">
                <TR>
                    <TD><xsl:value-of select="@errorType"/></TD>
                    <TD><xsl:value-of select="@description"/></TD>
                </TR>
            </xsl:for-each>
        </TABLE>
    </xsl:template>


    <!--
        Print detail information usefull for developers
      -->
    <xsl:template name="ASFALIS2006:ProcessDetailInfo">
        <HR/>
        <H2>Detailed Information</H2>
        <TABLE border="1">
            <xsl:for-each select="ASFALIS2006:OS">
                <TR>
                    <TH>OS</TH>
                    <TD><xsl:value-of select="@name"/></TD>
                    <TD><xsl:value-of select="@version"/></TD>
                </TR>
            </xsl:for-each>

            <xsl:for-each select="ASFALIS2006:CurrentDirectory">
                <TR>
                    <TH>Current working directory</TH>
                    <TD><xsl:value-of select="@pathName"/></TD>
                </TR>
            </xsl:for-each>

        </TABLE>

        <xsl:for-each select="ASFALIS2006:TranslationOptions">
            <xsl:call-template name="ASFALIS2006:PrintTranslationOptions"/>
        </xsl:for-each>

        <xsl:for-each select="ASFALIS2006:EntityNumberSets">
            <xsl:call-template name="ASFALIS2006:PrintEntityNumberSets"/>
        </xsl:for-each>
    </xsl:template>


    <!--
        Translation options
      -->
    <xsl:template name="ASFALIS2006:PrintTranslationOptions">
        <H4>Translation option</H4>
        <TABLE border="1">
            <xsl:for-each select="ASFALIS2006:TranslationOption">
                <TR>
                    <TD><xsl:value-of select="@title"/></TD>
                    <TD><xsl:value-of select="@value"/></TD>
                </TR>
            </xsl:for-each>
        </TABLE>
    </xsl:template>


    <!--
        Environment variables
      -->
    <xsl:template name="ASFALIS2006:PrintEnvironmentVariables">
        <H4>Environment variable</H4>
        <TABLE border="1">
            <xsl:for-each select="ASFALIS2006:EnvironmentVariable">
                <TR>
                    <TD><xsl:value-of select="@name"/></TD>
                    <TD><xsl:value-of select="@value"/></TD>
                </TR>
            </xsl:for-each>
        </TABLE>
    </xsl:template>


    <!--
        Entity numbers
      -->
    <xsl:template name="ASFALIS2006:PrintEntityNumberSets">
        <xsl:for-each select="ASFALIS2006:EntityNumberSet">
            <H4>Entity number
                <xsl:choose>
                    <xsl:when test="@entityInfoType='Original'">(Original data)</xsl:when>
                    <xsl:when test="@entityInfoType='Target'">(Result)</xsl:when>
                    <xsl:when test="@entityInfoType='DEK'">(ENF)</xsl:when>
                </xsl:choose>
            </H4>
            <TABLE border="1">
                <xsl:for-each select="ASFALIS2006:EntityNumber">
                    <TR>
                        <TH><xsl:value-of select="@entityTitle"/></TH>
                        <TD><xsl:value-of select="@number"/></TD>
                    </TR>
                </xsl:for-each>
            </TABLE>
        </xsl:for-each>
    </xsl:template>


    <!--
        Mass properties
      -->
    <xsl:template name="ASFALIS2006:PrintMassProperties">
        <H4>Mass property value</H4>
        <TABLE border="1">
            <xsl:for-each select="ASFALIS2006:DekEntity">
                    <TR><TH>Volume ID</TH><TD><xsl:value-of select="@dekId"/>
                    <xsl:for-each select="@cadId">
                        ( <xsl:value-of select="."/> )
                    </xsl:for-each>
                    </TD></TR>
            </xsl:for-each>

            <xsl:for-each select="ASFALIS2006:MassProperty">
                <TR>
                    <TH>
                        <xsl:choose>
                            <xsl:when test="@massType='Volume'">Volume</xsl:when>
                            <xsl:when test="@massType='SurfaceArea'">Surface area</xsl:when>
                            <xsl:when test="@massType='GravityPoint'">Gravity point</xsl:when>
                            <xsl:otherwise>Others</xsl:otherwise>
                        </xsl:choose>
                    </TH>

                    <TD><xsl:value-of select="@propertyValue"/></TD>

                    <TD>
                        <xsl:choose>
                            <xsl:when test="@entityInfoType='Original'">Original data</xsl:when>
                            <xsl:when test="@entityInfoType='DEK'">ENF</xsl:when>
                            <xsl:when test="@entityInfoType='Target'">Result</xsl:when>
                            <xsl:otherwise>その他</xsl:otherwise>
                        </xsl:choose>
                    </TD>
                </TR>
            </xsl:for-each>
        </TABLE>         
    </xsl:template>

  

   <xsl:template name="ASFALIS2006:PrintGeometryValidation">
     <xsl:for-each select="ASFALIS2006:CompareOptions">
       <H2>Comparison result</H2>
         <xsl:call-template name="ASFALIS2006:PrintCompareOptions"/>
     </xsl:for-each>

     <xsl:for-each select="ASFALIS2006:CompareResultSummary">
         <xsl:call-template name="ASFALIS2006:PrintCompareResultSummary"/>
     </xsl:for-each>
    
   </xsl:template>

   <xsl:template name="ASFALIS2006:PrintCompareOptions">
    <H4>Comparison option</H4>
      <TABLE border="1">
        <xsl:for-each select="ASFALIS2006:CompareOption">
           <TR>
             <TD><xsl:value-of select="@title"/></TD>
             <TD><xsl:value-of select="@value"/></TD>
           </TR>
        </xsl:for-each>
      </TABLE>
   </xsl:template>

   <xsl:template name="ASFALIS2006:PrintCompareResultSummary">
    <H4>Comparison result summary</H4>
    <TABLE border="1">      
      <xsl:for-each select="ASFALIS2006:CompareResultSummary">
           <TR>
             <TD><xsl:value-of select="@title"/></TD>
             <TD><xsl:value-of select="@value"/></TD>
           </TR>
        </xsl:for-each>
    </TABLE>
   </xsl:template>
   
</xsl:stylesheet>

