Prerequisites
Steps to reproduce
- Use the
Import-MamlHelp command to load a MamlHelp file that contains a <command:uri> element like the one shown below.
Import-MamlHelp -Path ./tmp/get-date.legacy-Help.xml
./tmp/get-date.legacy-Help.xml:
<?xml version="1.0" encoding="utf-8"?>
<helpItems xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" schema="maml" xmlns="http://msh">
<command:command>
<command:details>
<command:name>Get-Date</command:name>
<maml:description>
<maml:para>Gets the current date and time.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>Date</command:noun>
</command:details>
<maml:description>
<maml:para />
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-Date</maml:name>
</command:syntaxItem>
</command:syntax>
<command:parameters />
<command:inputTypes />
<command:returnValues />
<maml:alertSet>
<maml:alert>
<maml:para />
</maml:alert>
</maml:alertSet>
<command:examples />
<command:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online Version</maml:linkText>
<command:uri>https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-date?view=powershell-7.4&WT.mc_id=ps-gethelp</command:uri>
</maml:navigationLink>
</command:relatedLinks>
</command:command>
</helpItems>
Expected behavior
- The ability to import from MamlHelp
- To maintain compatibility, it must be able to read not only the new `<maml:uri>` but also the legacy `<command:uri>`
Note: PowerShell's built-in MAML reader (Get-Help / Show-HelpPreview)
correctly reads `<command:uri>`, so platyPS should maintain compatibility.
Actual behavior
An exception is thrown.
This issue exists independently of PR #849; the reader has always
expected `<maml:uri>` only and fails when `<command:uri>` is present.
Error details
PS> Get-Error -Newest 1
Exception :
Type : System.Xml.XmlException
Message : 'None' is an invalid XmlNodeType.
TargetSite :
Name : ReadEndElement
DeclaringType : [System.Xml.XmlReader]
MemberType : Method
Module : System.Private.Xml.dll
Source : System.Private.Xml
HResult : -2146232000
StackTrace :
at System.Xml.XmlReader.ReadEndElement()
at Microsoft.PowerShell.PlatyPS.TransformMaml.ReadRelatedLinks(XmlReader reader) in /home/teramako/var/powershell/platyPS/src/Transform/TransformMaml.cs:line 158
at Microsoft.PowerShell.PlatyPS.TransformMaml.ReadCommand(String moduleName, XmlReader reader) in /home/teramako/var/powershell/platyPS/src/Transform/TransformMaml.cs:line 108
at Microsoft.PowerShell.PlatyPS.TransformMaml.ReadMaml(String mamlFile) in /home/teramako/var/powershell/platyPS/src/Transform/TransformMaml.cs:line 70
at Microsoft.PowerShell.PlatyPS.TransformMaml.Transform(String[] mamlFileNames) in /home/teramako/var/powershell/platyPS/src/Transform/TransformMaml.cs:line 37
at Microsoft.PowerShell.PlatyPS.ImportMamlHelpCommand.ProcessRecord() in /home/teramako/var/powershell/platyPS/src/Command/ImportMamlCommand.cs:line 49
TargetObject : /home/teramako/var/powershell/platyPS/tmp/get-date.legacy-Help.xml
CategoryInfo : InvalidOperation: (/home/teramako/var/…ate.legacy-Help.xml:String) [Import-MamlHelp], XmlException
FullyQualifiedErrorId : FailedToTransformMaml,Microsoft.PowerShell.PlatyPS.ImportMamlHelpCommand
InvocationInfo :
MyCommand : Import-MamlHelp
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 10
Line : Import-MamlHelp -Path ./tmp/get-date.legacy-Help.xml
Statement : Import-MamlHelp -Path ./tmp/get-date.legacy-Help.xml
PositionMessage : At line:1 char:1
+ Import-MamlHelp -Path ./tmp/get-date.legacy-Help.xml
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Import-MamlHelp
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
0
1
Environment data
Name Value
---- -----
PSVersion 7.6.3
PSEdition Core
GitCommitId 7.6.3
OS Ubuntu 24.04.4 LTS
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
1.0.2
Visuals
No response
Prerequisites
Steps to reproduce
Import-MamlHelpcommand to load a MamlHelp file that contains a<command:uri>element like the one shown below.Import-MamlHelp -Path ./tmp/get-date.legacy-Help.xml./tmp/get-date.legacy-Help.xml:
Expected behavior
Actual behavior
Error details
Environment data
Version
1.0.2
Visuals
No response