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

Ask A Question

Stats

  • Questions 322k
  • Answers 322k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I will assume that you have an object that hold… May 14, 2026 at 12:48 am
  • Editorial Team
    Editorial Team added an answer You're looking for the "CoreLocation" API. Here's a tutorial May 14, 2026 at 12:48 am
  • Editorial Team
    Editorial Team added an answer When configuring the UPDATE behavior to use the update stored… May 14, 2026 at 12:48 am

Related Questions

I'm trying to genererate thumbnails from image files stored in a folder under the
I am attempting to have a ReportHandler service to handle report creation. Reports can
I am currently coding a HTML website into wordpress. The problem that i'm having
I am currently working on designing my first FPS game using JOGL. (Java bindings

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.