Skip to content

Commit 0411463

Browse files
committed
Improving xml
1 parent 07b2718 commit 0411463

6 files changed

Lines changed: 122 additions & 56 deletions

File tree

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,48 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<system-prompt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="spml.xsd"
4-
id="100-java-checklist-guide" version="1.0">
2+
<prompt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="spml-1.1.xsd"
4+
id="100-java-checklist-guide" version="1.0">
5+
56
<metadata>
6-
<description></description>
7-
<globs></globs>
8-
<always-apply>false</always-apply>
7+
<cursor-ai>
8+
<description></description>
9+
<globs></globs>
10+
<always-apply>false</always-apply>
11+
</cursor-ai>
912
<tags>
1013
<tag>java</tag>
1114
<tag>checklist</tag>
1215
<tag>cursor-rules</tag>
1316
</tags>
1417
<version>0.8.0</version>
18+
<title>Create a Checklist with all Java steps to use with cursor rules for Java</title>
1519
</metadata>
1620

17-
<header>
18-
<title>Create a Checklist with all Java steps to use with cursor rules for Java</title>
19-
</header>
21+
<goal>
22+
Your task is to create a comprehensive step-by-step guide that follows the exact format and structure defined in the embedded template below.
2023

21-
<system-characterization>
22-
<role-definition>You are a Senior software engineer with extensive experience in Java programming language and technical documentation</role-definition>
23-
</system-characterization>
24+
Create a markdown file named `CURSOR-RULES-JAVA.md` with the following exact structure: [java-checklist-template.md](mdc:.cursor/rules/templates/java-checklist-template.md)
25+
</goal>
2426

25-
<description>
26-
Your task is to create a comprehensive step-by-step guide that follows the exact format and structure defined in the embedded template below.
27-
</description>
27+
<role>You are a Senior software engineer with extensive experience in Java programming language and technical documentation</role>
2828

29-
<content-sections>
30-
<instruction-section>
31-
<instruction-title>Instructions for AI</instruction-title>
32-
<instruction-description>Create a markdown file named `CURSOR-RULES-JAVA.md` with the following exact structure: [java-checklist-template.md](mdc:.cursor/rules/templates/java-checklist-template.md)</instruction-description>
33-
<restrictions>
34-
<restrictions-description>**MANDATORY REQUIREMENT**: Follow the embedded template EXACTLY - do not add, remove, or modify any steps, sections, or cursor rules that are not explicitly shown in the template. ### What NOT to Include:</restrictions-description>
35-
<restriction-list>
36-
<restriction>**DO NOT** create additional steps beyond what's shown in the template</restriction>
37-
<restriction>**DO NOT** add cursor rules that are not explicitly listed in the embedded template</restriction>
38-
<restriction>**DO NOT** expand or elaborate on sections beyond what the template shows</restriction>
39-
<restriction>**ONLY** use cursor rules that appear in the embedded template</restriction>
40-
<restriction>**ONLY** use the exact wording and structure from the template</restriction>
41-
<restriction>If a cursor rule exists in the workspace but is not in the template, **DO NOT** include it</restriction>
42-
</restriction-list>
43-
</restrictions>
44-
</instruction-section>
29+
<restrictions>
30+
<restrictions-description>**MANDATORY REQUIREMENT**: Follow the embedded template EXACTLY - do not add, remove, or modify any steps, sections, or cursor rules that are not explicitly shown in the template. ### What NOT to Include:</restrictions-description>
31+
<restriction-list>
32+
<restriction>**DO NOT** create additional steps beyond what's shown in the template</restriction>
33+
<restriction>**DO NOT** add cursor rules that are not explicitly listed in the embedded template</restriction>
34+
<restriction>**DO NOT** expand or elaborate on sections beyond what the template shows</restriction>
35+
<restriction>**ONLY** use cursor rules that appear in the embedded template</restriction>
36+
<restriction>**ONLY** use the exact wording and structure from the template</restriction>
37+
<restriction>If a cursor rule exists in the workspace but is not in the template, **DO NOT** include it</restriction>
38+
</restriction-list>
39+
</restrictions>
4540

46-
<output-requirements-section>
47-
<output-requirements-title>Output Requirements</output-requirements-title>
48-
<output-requirements-rules>
49-
<output-requirements-rule>Generate the complete markdown file following the embedded template exactly</output-requirements-rule>
50-
<output-requirements-rule>Use proper markdown formatting with headers, code blocks, tables, and checklists</output-requirements-rule>
51-
<output-requirements-rule>**VERIFY**: Final output contains ONLY what appears in the embedded template</output-requirements-rule>
52-
</output-requirements-rules>
53-
</output-requirements-section>
54-
</content-sections>
55-
</system-prompt>
41+
<output-requirements-section>
42+
<output-requirements-rules>
43+
<output-requirements-rule>Generate the complete markdown file following the embedded template exactly</output-requirements-rule>
44+
<output-requirements-rule>Use proper markdown formatting with headers, code blocks, tables, and checklists</output-requirements-rule>
45+
<output-requirements-rule>**VERIFY**: Final output contains ONLY what appears in the embedded template</output-requirements-rule>
46+
</output-requirements-rules>
47+
</output-requirements-section>
48+
</prompt>

spml/src/main/resources/cursor-rule-generator-1.1.xsl

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ alwaysApply: </xsl:text><xsl:value-of select="normalize-space(metadata/cursor-ai
2424
<!-- Process goal (Instructions for AI) before role -->
2525
<xsl:apply-templates select="goal"/>
2626
<xsl:text>
27-
2827
## Role
2928

3029
</xsl:text><xsl:value-of select="role"/>
30+
<xsl:text>
31+
32+
</xsl:text>
33+
<!-- Apply restrictions template if present -->
34+
<xsl:apply-templates select="restrictions"/>
3135

3236
<!-- Examples section with auto-generated table of contents -->
3337
<xsl:if test="examples/toc[@auto-generate='true']">
@@ -130,7 +134,9 @@ Description: </xsl:text> <xsl:value-of select="normalize-space(example-de
130134
## Instructions for AI
131135

132136
</xsl:text>
133-
<xsl:value-of select="normalize-space(.)"/>
137+
<xsl:call-template name="trim-goal-content">
138+
<xsl:with-param name="content" select="."/>
139+
</xsl:call-template>
134140
</xsl:template>
135141

136142
<!-- Output requirements section template - handles both complex and simple structures -->
@@ -156,7 +162,7 @@ Description: </xsl:text> <xsl:value-of select="normalize-space(example-de
156162

157163
<!-- Restrictions template -->
158164
<xsl:template match="restrictions">
159-
<xsl:text>### Restrictions
165+
<xsl:text>## Restrictions
160166

161167
</xsl:text>
162168
<xsl:if test="restrictions-description">
@@ -235,4 +241,70 @@ Description: </xsl:text> <xsl:value-of select="normalize-space(example-de
235241
</xsl:otherwise>
236242
</xsl:choose>
237243
</xsl:template>
244+
245+
<!-- Template to trim goal content while preserving paragraph structure -->
246+
<xsl:template name="trim-goal-content">
247+
<xsl:param name="content"/>
248+
<xsl:variable name="trimmed-start">
249+
<xsl:choose>
250+
<xsl:when test="starts-with($content, '&#10;')">
251+
<xsl:value-of select="substring($content, 2)"/>
252+
</xsl:when>
253+
<xsl:otherwise>
254+
<xsl:value-of select="$content"/>
255+
</xsl:otherwise>
256+
</xsl:choose>
257+
</xsl:variable>
258+
<xsl:variable name="trimmed-both">
259+
<xsl:choose>
260+
<xsl:when test="substring($trimmed-start, string-length($trimmed-start)) = '&#10;'">
261+
<xsl:value-of select="substring($trimmed-start, 1, string-length($trimmed-start) - 1)"/>
262+
</xsl:when>
263+
<xsl:otherwise>
264+
<xsl:value-of select="$trimmed-start"/>
265+
</xsl:otherwise>
266+
</xsl:choose>
267+
</xsl:variable>
268+
<xsl:call-template name="remove-goal-indentation">
269+
<xsl:with-param name="text" select="$trimmed-both"/>
270+
</xsl:call-template>
271+
</xsl:template>
272+
273+
<!-- Remove leading spaces from each line while preserving paragraph structure -->
274+
<xsl:template name="remove-goal-indentation">
275+
<xsl:param name="text"/>
276+
<xsl:choose>
277+
<xsl:when test="contains($text, '&#10;')">
278+
<xsl:variable name="line" select="substring-before($text, '&#10;')"/>
279+
<xsl:variable name="rest" select="substring-after($text, '&#10;')"/>
280+
<xsl:call-template name="ltrim">
281+
<xsl:with-param name="string" select="$line"/>
282+
</xsl:call-template>
283+
<xsl:text>&#10;</xsl:text>
284+
<xsl:call-template name="remove-goal-indentation">
285+
<xsl:with-param name="text" select="$rest"/>
286+
</xsl:call-template>
287+
</xsl:when>
288+
<xsl:otherwise>
289+
<xsl:call-template name="ltrim">
290+
<xsl:with-param name="string" select="$text"/>
291+
</xsl:call-template>
292+
</xsl:otherwise>
293+
</xsl:choose>
294+
</xsl:template>
295+
296+
<!-- Left trim (remove leading spaces) -->
297+
<xsl:template name="ltrim">
298+
<xsl:param name="string"/>
299+
<xsl:choose>
300+
<xsl:when test="substring($string, 1, 1) = ' '">
301+
<xsl:call-template name="ltrim">
302+
<xsl:with-param name="string" select="substring($string, 2)"/>
303+
</xsl:call-template>
304+
</xsl:when>
305+
<xsl:otherwise>
306+
<xsl:value-of select="$string"/>
307+
</xsl:otherwise>
308+
</xsl:choose>
309+
</xsl:template>
238310
</xsl:stylesheet>

spml/src/main/resources/spml-1.1.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<xs:element ref="metadata"/>
1010
<xs:element ref="goal" minOccurs="0"/>
1111
<xs:element ref="role"/>
12+
<xs:element ref="restrictions" minOccurs="0"/>
1213
<xs:element ref="examples" minOccurs="0"/>
1314
<xs:element ref="output-requirements-section" minOccurs="0"/>
1415
</xs:sequence>

spml/src/test/java/info/jab/xml/CursorRuleGeneratorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void should_generateExactContentMatchingOriginalExpected_when_transformingJavaCh
9898
String expectedContent = loadExpectedContent("100-java-checklist-guide.mdc");
9999

100100
// When
101-
String actualResult = generator.generate("100-java-checklist-guide.xml", "cursor-rule-generator.xsl");
101+
String actualResult = generator.generate("100-java-checklist-guide.xml", "cursor-rule-generator-1.1.xsl", "spml-1.1.xsd");
102102

103103
// Then - Unified XSLT should produce identical output to expected
104104
assertThat(actualResult)
@@ -301,7 +301,7 @@ void should_produceConsistentStructure_when_processingDifferentXmlTypes() throws
301301
CursorRuleGenerator generator = new CursorRuleGenerator();
302302

303303
// When
304-
String checklistGuideResult = generator.generate("100-java-checklist-guide.xml", "cursor-rule-generator.xsl");
304+
String checklistGuideResult = generator.generate("100-java-checklist-guide.xml", "cursor-rule-generator-1.1.xsl", "spml-1.1.xsd");
305305
String bestPracticesResult = generator.generate("110-java-maven-best-practices.xml", "cursor-rule-generator-1.1.xsl", "spml-1.1.xsd");
306306
String documentationResult = generator.generate("112-java-maven-documentation.xml", "cursor-rule-generator.xsl");
307307
String objectOrientedDesignResult = generator.generate("121-java-object-oriented-design.xml", "cursor-rule-generator.xsl");

spml/src/test/resources/100-java-checklist-guide.mdc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ alwaysApply: false
55
---
66
# Create a Checklist with all Java steps to use with cursor rules for Java
77

8-
## System prompt characterization
9-
10-
Role definition: You are a Senior software engineer with extensive experience in Java programming language and technical documentation
11-
12-
## Description
8+
## Instructions for AI
139

1410
Your task is to create a comprehensive step-by-step guide that follows the exact format and structure defined in the embedded template below.
1511

16-
## Instructions for AI
17-
1812
Create a markdown file named `CURSOR-RULES-JAVA.md` with the following exact structure: [java-checklist-template.md](mdc:.cursor/rules/templates/java-checklist-template.md)
1913

20-
### Restrictions
14+
## Role
15+
16+
You are a Senior software engineer with extensive experience in Java programming language and technical documentation
17+
18+
## Restrictions
2119

2220
**MANDATORY REQUIREMENT**: Follow the embedded template EXACTLY - do not add, remove, or modify any steps, sections, or cursor rules that are not explicitly shown in the template. ### What NOT to Include:
2321

@@ -33,4 +31,4 @@ Create a markdown file named `CURSOR-RULES-JAVA.md` with the following exact str
3331

3432
- Generate the complete markdown file following the embedded template exactly
3533
- Use proper markdown formatting with headers, code blocks, tables, and checklists
36-
- **VERIFY**: Final output contains ONLY what appears in the embedded template
34+
- **VERIFY**: Final output contains ONLY what appears in the embedded template

spml/src/test/resources/110-java-maven-best-practices.mdc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Update the pom.xml based on the following rules about Maven best practices.
1313

1414
You are a Senior software engineer with extensive experience in Java software development
1515

16+
17+
1618
## Examples
1719

1820
### Table of contents
@@ -588,4 +590,4 @@ Description: Define all dependency and plugin versions in the `<properties>` sec
588590
## Output Requirements
589591

590592
- Update the file pom.xml if something is not correct
591-
- verify changes with the command: `mvn validate`
593+
- verify changes with the command: `mvn validate`

0 commit comments

Comments
 (0)