Skip to content

fix(sitemap): correct element ordering for Titles/Descriptions in all entry types#325

Merged
rnwood merged 5 commits into
mainfrom
copilot/fix-dataversesitemapentry-validation
Dec 9, 2025
Merged

fix(sitemap): correct element ordering for Titles/Descriptions in all entry types#325
rnwood merged 5 commits into
mainfrom
copilot/fix-dataversesitemapentry-validation

Conversation

Copilot AI commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Description

The Set-DataverseSitemapEntry cmdlet failed XSD validation when adding Titles or Descriptions to sitemap elements (Area, Group, SubArea) containing existing children. The Dataverse XSD schema enforces strict element ordering, but elements were appended at the end, placing them after child elements and violating the schema requirements.

Changes Made

  • UpdateTitlesElement(): Changed Add() to AddFirst() to insert Titles before existing children
  • UpdateDescriptionsElement(): Insert after Titles if present, otherwise at beginning
  • Test coverage: Added tests verifying proper element ordering per XSD schema for all entry types:
    • Area: Titles → Descriptions → Group
    • Group: Titles → Descriptions → SubArea
    • SubArea: Titles → Descriptions → Privilege

Example command that now works:

Set-DataverseSitemapEntry -sitemapUniqueName "sitemap" -Area -entryid "area_main" -Titles @{1033="Main"}

Generates XSD-compliant XML:

<Area Id="area_main">
  <Titles><Title LCID="1033" Title="Main" /></Titles>
  <Descriptions>...</Descriptions>
  <Group Id="..." />
</Area>

The fix applies to all sitemap entry types (Area, Group, SubArea) since the methods are generic and used across all types.

Testing

  • Unit tests pass (83 sitemap tests, including 3 new element ordering tests)
  • E2E tests pass (if applicable)
  • Manual testing completed

Checklist

  • Code follows the project's coding conventions
  • Documentation updated (if needed)
  • Tests added/updated (if needed)
  • PR title uses conventional commit format (REQUIRED)
Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] set-DataverseSitemapEntry -sitemapUniqueName "some_name" -Area -entryid area_main -Titles fails with XSD validation</issue_title>
<issue_description>### Description

set-DataverseSitemapEntry -sitemapUniqueName "some_name" -Area -entryid area_main -Titles @{1033="Main"}
Set-DataverseSitemapEntry: Sitemap xml failed XSD validation with the following error: 'The element 'Area' has invalid child element 'Titles'. List of possible elements expected: 'Group'.' at line 150 position 6.

Steps to Reproduce

Expected Behavior

Actual Behavior

PowerShell version

Module Version

No response

Additional Context

No response

Checklist

  • I have tried the latest version of the module
  • I have searched for similar issues and couldn't find any
  • I have included all the information needed to reproduce the issue</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 8, 2025 17:03
…order

Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix XSD validation error in set-DataverseSitemapEntry fix(sitemap): correct XSD element ordering for Titles/Descriptions in Areas Dec 8, 2025
Copilot AI requested a review from rnwood December 8, 2025 17:14
@rnwood rnwood changed the title fix(sitemap): correct XSD element ordering for Titles/Descriptions in Areas fix(sitemap): correct element ordering for Titles/Descriptions in Areas Dec 8, 2025
@rnwood

rnwood commented Dec 8, 2025

Copy link
Copy Markdown
Collaborator

@copilot apply this same ordering to the other entry types too

Co-authored-by: rnwood <1327895+rnwood@users.noreply.github.com>

Copilot AI commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

@copilot apply this same ordering to the other entry types too

Done! The element ordering fix already applies to all entry types (Area, Group, SubArea) since UpdateTitlesElement() and UpdateDescriptionsElement() are generic methods. I've added comprehensive tests to verify the ordering for each type:

  • Areas: Titles → Descriptions → Group
  • Groups: Titles → Descriptions → SubArea
  • SubAreas: Titles → Descriptions → Privilege

All 83 sitemap tests pass. See commit b9e228c.

Copilot AI changed the title fix(sitemap): correct element ordering for Titles/Descriptions in Areas fix(sitemap): correct element ordering for Titles/Descriptions in all entry types Dec 8, 2025
Copilot AI requested a review from rnwood December 8, 2025 19:13
@rnwood rnwood marked this pull request as ready for review December 9, 2025 06:07
@rnwood rnwood merged commit 86c7bb8 into main Dec 9, 2025
15 of 16 checks passed
@rnwood rnwood deleted the copilot/fix-dataversesitemapentry-validation branch December 9, 2025 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] set-DataverseSitemapEntry -sitemapUniqueName "some_name" -Area -entryid area_main -Titles fails with XSD validation

2 participants