Jump to content

Customize Autodesk Civil 3D XML Data into Table


Recommended Posts

Hello all, first time poster on the forum and I can get some insight on how to solve a problem I am having. I hope its rewarding for you as well.

 

A little background, I am using an xml file that is exported from Autodesk Civil 3D that list Pay Items, Quantities, and Units for Road Construction estimates. My goal is to harness this xml file to include unit prices and then create a total cost per pay item. You will see there is a field for <estimatedUnitPrice> and I would but in a price there for each item.

 

For now I can not even use the xsl file and the html file to get a table to generate that will list each pay item. Below is the code, and I have attached a picture of the results of running this code via Visual Web Developer Express, as may see it will not list the pay item <gml:description> which I expect.

 

 

 

XML file Named "Summary (XML)" This file comes directly from Autodesk Civil 3D, I only have one pay item listed here for brevity

sake, normally there would be many <item> sections.

 <?xml version="1.0" encoding="UTF-8"?><DesignProject xsi:schemaLocation="http://www.transxml.net/schema/dp/0.3 DP-GML20060123pxs.xsd" gml:id="ID001" xmlns="http://www.transxml.net/schema/dp/0.3" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:txl="http://www.transxml.net/schema/txl/0.3" xmlns:rpi="http://www.transxml.net/schema/rpi/0.3" xmlns:lr="http://www.transxml.net/schema/lr/0.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">    <gml:name>design project</gml:name>    <gml:description></gml:description>    <projectID>ID001</projectID>    <unitSystem>english</unitSystem>    <group>        <DesignProjectPayItemGroup gml:id="dppig1">            <gml:description></gml:description>            <designProjectPayItemGroupID>dppig1</designProjectPayItemGroupID>            <item>                <DesignProjectPayItem gml:id="id">                    <sequenceOrder>0</sequenceOrder>                    <estimatedUnitPrice>0</estimatedUnitPrice>                    <estimatedQuantity>4558.445</estimatedQuantity>                    <referencePayItem>                        <ReferencePayItem gml:id="60201-0600" xmlns="http://www.transxml.net/schema/ref/0.3">                            <gml:description>18-INCH PIPE CULVERT</gml:description>                            <referencePayItemID>60201-0600</referencePayItemID>                            <specBookVersion></specBookVersion>                            <lumpSum>false</lumpSum>                            <supplementalDescriptionRequired>false</supplementalDescriptionRequired>                            <unit>                                <txl:UnitOfMeasure>                                    <txl:unitOfMeasureID>LNFT</txl:unitOfMeasureID>                                    <txl:unitSystem></txl:unitSystem>                                </txl:UnitOfMeasure>                            </unit>                        </ReferencePayItem>                    </referencePayItem>                    <referenceInformation xmlns="Civil3D.QTO.Computation">                        <unitType>linear</unitType>                        <listSeparator>,</listSeparator>                    </referenceInformation>                </DesignProjectPayItem>            </item>        </DesignProjectPayItemGroup>    </group></DesignProject>

XSL File Named "Detailed" I got thie file from an example for W3Schools Tutorials. I changed only what was in bold, and deleted a second column that was in the org example.

<?xml version="1.0" encoding="iso-8859-1"?><!-- Edited by XMLSpy® --><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">    <xsl:template match="/">        <html>            <body>                <h2>My CD Collection</h2>                <table border="1">                    <tr bgcolor="#9acd32">                        <th>Description</th>                    </tr>                    <xsl:for-each select="DesignProject/group/DesignProjectPayItemGroup/item/DesignProjectPayItem/ReferencePayItem">                        <tr>                            <td>                                <xsl:value-of select="gml:description" />                            </td>                        </tr>                    </xsl:for-each>                </table>            </body>        </html>    </xsl:template></xsl:stylesheet>

HTM file named "Detailed" Again this file source code came from a tutorial and I changed the file names that are in bold below.

<html><head><script>    function loadXMLDoc(filename) {        if (window.ActiveXObject) {            xhttp = new ActiveXObject("Msxml2.XMLHTTP");        }        else {            xhttp = new XMLHttpRequest();        }        xhttp.open("GET", filename, false);        try { xhttp.responseType = "msxml-document" } catch (err) { } // Helping IE11        xhttp.send("");        return xhttp.responseXML; cription    }    function displayResult() {        xml = loadXMLDoc("Summary (XML).xml");        xsl = loadXMLDoc("Detailed.xsl");        // code for IE        if (window.ActiveXObject || xhttp.responseType == "msxml-document") {            ex = xml.transformNode(xsl);            document.getElementById("example").innerHTML = ex;        }        // code for Chrome, Firefox, Opera, etc.        else if (document.implementation && document.implementation.createDocument) {            xsltProcessor = new XSLTProcessor();            xsltProcessor.importStylesheet(xsl);            resultDocument = xsltProcessor.transformToFragment(xml, document);            document.getElementById("example").appendChild(resultDocument);        }    }</script></head><body onload="displayResult()"><div id="example" /></body></html>

post-172242-0-49200400-1396352437_thumb.png

 

 

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...