XML Schema Guide

Structure Creator uses XML to define folder and file structures. This guide covers all the available elements and attributes.

Schema Sources

You can define schemas in three ways:

XML Editor

Click the XML tab in the center panel to write XML directly. This gives you full control over the structure, variables, and content. The editor features syntax highlighting, auto-formatting, and real-time validation.

You can also use the Visual tab for a drag-and-drop editor, or the Preview tab to see a read-only tree view.

Import from Folder

Scan an existing folder to generate a schema automatically:

  1. Click the folder icon in the schema toolbar
  2. Select a folder to scan
  3. Structure Creator generates XML representing that folder's structure

This is useful for:

  • Creating templates from existing projects
  • Documenting current folder structures
  • Starting with a base structure and customizing it

Import from ZIP

Use a ZIP archive as your schema source:

  1. Click the import icon in the schema toolbar
  2. Select a .zip file
  3. Structure Creator extracts and generates the schema

ZIP import preserves the complete folder hierarchy and all file contents, making it easy to share templates or create structures from archived projects.

Basic Elements

Folders

Use the <folder> element to create directories:

<folder name="src">
  <!-- child elements go here -->
</folder>

Folders can be nested:

<folder name="src">
  <folder name="components">
    <folder name="ui" />
  </folder>
</folder>

Files

Use the <file> element to create files:

<file name="index.ts" />

Structure Creator supports any file type—code files, documents (.docx, .pdf), images, binaries, and more. For text files, you can include content directly. For binary files, use the url attribute to download from a remote source.

File Content

Add content directly inside the element:

<file name="README.md">
# My Project

Welcome to my project!
</file>

CDATA for Special Characters

When file content contains XML-reserved characters like <, >, or &, wrap it in a CDATA section to avoid escaping:

<file name="App.tsx"><![CDATA[
import React from 'react';

export const App = () => {
  return <div className="app">Hello & welcome!</div>;
};
]]></file>

Without CDATA, you'd need to escape these characters (&lt;, &gt;, &amp;). CDATA is especially useful for:

  • JSX/TSX files with angle brackets
  • HTML templates
  • Code containing && or comparison operators
  • Any content with ampersands

For plain text like Markdown or config files without special characters, CDATA is not required.

Dynamic File Content

For files that need conditional content or loops inside them, add template="true":

<file name="README.md" template="true">
{{if INCLUDE_BADGES}}
![Build Status](https://img.shields.io/badge/build-passing-green)
{{endif}}

# %PROJECT_NAME%
</file>

This enables {{if VAR}}...{{endif}} conditionals and {{for item in VAR}}...{{endfor}} loops within file content. See the Conditionals & Loops guide for full documentation.

File from URL

Download content from a URL:

<file name="tsconfig.json" url="https://example.com/tsconfig.json" />

SVG Files

SVG files are treated as text/XML and fully support variable substitution:

<file name="logo.svg">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
  <text x="50" y="50" text-anchor="middle">%PROJECT_NAME%</text>
</svg>
</file>

This makes SVGs ideal for creating dynamic logos, icons, or diagrams with project-specific text or values.

File Generators

Generate binary files directly without needing external sources:

<!-- Generate a placeholder image -->
<file name="logo.png" generate="image" width="200" height="200" background="#3B82F6" />

<!-- Generate a SQLite database -->
<file name="app.db" generate="sqlite"><![CDATA[
CREATE TABLE users (id INTEGER PRIMARY KEY, email TEXT NOT NULL);
]]></file>

See the File Generators guide for complete documentation on image and SQLite generation.

Variables

Use %VARIABLE_NAME% syntax for dynamic values:

<folder name="%PROJECT_NAME%">
  <file name="%COMPONENT_NAME%.tsx" />
</folder>

Variables are automatically detected and shown in the UI for you to fill in.

Transforms

Apply transformations to variables:

<file name="%NAME:kebab-case%.ts" />

Available transforms:

  • uppercase - HELLO WORLD
  • lowercase - hello world
  • camelCase - helloWorld
  • PascalCase - HelloWorld
  • kebab-case - hello-world
  • snake_case - hello_world
  • plural - cats
  • length - 5

See the Variables guide for more details on transforms and date formatting.

Control Flow

Conditionals

Include content conditionally with <if>:

<if var="INCLUDE_TESTS">
  <folder name="tests">
    <file name="index.test.ts" />
  </folder>
</if>

Add an <else> block:

<if var="USE_TYPESCRIPT">
  <file name="index.ts" />
</if>
<else>
  <file name="index.js" />
</else>

Loops

Repeat content with <repeat>:

<repeat count="3" as="i">
  <file name="file-%i%.txt" />
</repeat>

This creates:

  • file-0.txt
  • file-1.txt
  • file-2.txt

Use %i_1% for 1-indexed values:

<repeat count="3" as="n">
  <folder name="module-%n_1%">
    <file name="index.ts" />
  </folder>
</repeat>

Hooks

Hooks let you run commands automatically after your structure is created. This is useful for initializing git repositories, installing dependencies, or running setup scripts.

Post-Create Hook

Use the <hooks> element with <post-create> children to run commands after structure creation:

<folder name="%PROJECT_NAME%">
  <file name="package.json">
{
  "name": "%PROJECT_NAME:kebab-case%",
  "version": "1.0.0"
}
  </file>

  <hooks>
    <post-create>npm install</post-create>
  </hooks>
</folder>

Multiple Commands

You can specify multiple post-create commands. They run in order:

<hooks>
  <post-create>git init</post-create>
  <post-create>npm install</post-create>
  <post-create>npm run build</post-create>
</hooks>

Working Directory

Commands run from the root of the created structure (the top-level folder).

Common Use Cases

<!-- Initialize a git repository -->
<hooks>
  <post-create>git init</post-create>
  <post-create>git add .</post-create>
  <post-create>git commit -m "Initial commit"</post-create>
</hooks>

<!-- Install dependencies for different package managers -->
<hooks>
  <post-create>pnpm install</post-create>
</hooks>

<!-- Run setup scripts -->
<hooks>
  <post-create>chmod +x ./scripts/setup.sh</post-create>
  <post-create>./scripts/setup.sh</post-create>
</hooks>

Complete Example

<folder name="%PROJECT_NAME%">
  <folder name="src">
    <folder name="components">
      <repeat count="%NUM_COMPONENTS%" as="i">
        <folder name="%COMPONENT_PREFIX%Component%i_1%">
          <file name="index.tsx" />
          <if var="INCLUDE_STYLES">
            <file name="styles.css" />
          </if>
        </folder>
      </repeat>
    </folder>
    <file name="main.tsx" />
  </folder>
  <file name="package.json" url="https://..." />
  <file name="README.md">
# %PROJECT_NAME%

Created with Structure Creator.
  </file>
</folder>