Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 355101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:59:11+00:00 2026-05-12T11:59:11+00:00

I am currently trying to generate the creation SQL for my tables based off

  • 0

I am currently trying to generate the creation SQL for my tables based off of a Visio diagram. I am doing this using the approach found here.

http://www.dougboude.com/blog/1/2008/11/SQL-Forward-Engineering-with-Visio-2003-Professional.cfm

I am attempting to modify the xslt file found there to better model the syntax that we use in our office. Unfortunately, I cannot get the part that involves passing the table name into the template for the table columns to work. The template gets called, but it seems to ignore my parameters.

<xsl:template match="Entity" mode="table">
IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = '<xsl:value-of select="@PhysicalName"/>')
<br />
CREATE TABLE dbo.[<xsl:value-of select="@PhysicalName"/>]
(
<br />
<xsl:for-each select="EntityAttributes/EntityAttribute">
    <span style="padding-left: 20px;">
        <xsl:apply-templates select="../../../../Attributes/Attribute[@AttributeID = current()/@EntityAttributeID]" mode="table">
            <xsl:with-param name="EntityName" select="@PhysicalName" />
        </xsl:apply-templates>
    </span>
    <xsl:if test="count(../../EntityAttributes/EntityAttribute) != position()">,</xsl:if>
    <br />
</xsl:for-each>
)
<br />
GO
<p />

<xsl:apply-templates select="EntityAnnotations/EntityAnnotation[@AnnotationType='Primary Key']" mode="pk"/>
<xsl:apply-templates select="EntityAnnotations/EntityAnnotation[@AnnotationType='Alternate Key']" mode="ak"/>
<xsl:apply-templates select="EntityAnnotations/EntityAnnotation[@AnnotationType='Index']" mode="idx"/>
</xsl:template>

<!-- Create column for each EntityAttribute -->
<xsl:template match="Attribute" mode="table">
    <xsl:param name="EntityName"></xsl:param>
    <xsl:variable name="nullability">
        <xsl:choose>
            <xsl:when test='@AllowNulls = "false"'>NOT NULL CONSTRAINT DF_<xsl:value-of select="$EntityName" />_<xsl:value-of select="@PhysicalName"/>
        </xsl:when>
            <xsl:otherwise> NULL</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="incremental">
        <xsl:choose>
            <xsl:when test='@PhysicalDatatype = "int identity"'> INT IDENTITY(1,1)</xsl:when>
            <xsl:otherwise><xsl:value-of select="@PhysicalDatatype"/></xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

[<xsl:value-of select="@PhysicalName"/>] <span style="text-transform:uppercase;">   <xsl:value-of select="$incremental"/></span>  <xsl:value-of select="$nullability"/>

</xsl:template>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:59:12+00:00Added an answer on May 12, 2026 at 11:59 am

    The parameter is not ignored, but I guess it is empty. You call:

    <xsl:with-param name="EntityName" select="@PhysicalName" />
    

    where @PhysicalName must be an attribute of EntityAttributes/EntityAttribute element from the for-each. The fact that you use @PhysicalName earlier in

    CREATE TABLE dbo.[<xsl:value-of select="@PhysicalName"/>]
    

    makes me think in reality it is an attribute of the Entity element the template matches. You need to store its value in a variable first (before the for-each):

    <xsl:variable name="PhysicalName" select="@PhysicalName" />
    

    and then use it like this:

    <xsl:with-param name="EntityName" select="$PhysicalName" />
    <!-- -------------------------------------^  -->
    

    The for-each resets the context node with every iteration, I guess this is where it goes wrong for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to pass a mono threaded program to multithread. This software do
I am currently trying to implement basic speech recognition in AS3. I need this
I am trying to generate random floats using nothing but bytes I get from
I am trying to generate a report using Oracle but am having some alignment
I'm trying to generate a dynamic property in a framework I'm using, and I'm
I currently trying to find a solution, how to ensure that a test fails
I'm currently trying to read in an XML file, make some minor changes (alter
I'm currently trying out db4o (the java version) and I pretty much like what
I'm currently trying to build a personal website to create a presence on the
I'm currently trying to port a SIP stack library (pjSIP) to the PSP Console

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.