Skip to content

Data-type XML element names aren't spec-compliant #4

@mklement0

Description

@mklement0

The data-type XML element names used by ConvertTo-XmlRpcType aren't spec-compliant, in that they start with a capital letter when they should all be all-lowercase (e.g. <String> instead of <string>), and <Int32> should be <int> (base64 isn't covered by this module).

As a stopgap, you can employ the following workaround: correct the problem in a post-processing step; e.g.:

# Sample call
$result = 
  ConvertTo-XmlRpcMethodCall -Name LJ.XMLRPC.getevents @{
    int = 42
    double = 3.14
    boolean = $true
    date = Get-Date
    array = 'one & two', 3
  } 

# Post-process the results to make the data-type element
# names conform to the spec.
# ('Double' -> 'double', ..., and 'Int32' -> 'int')
[regex]::Replace(
  $result,
  '(</?)([A-Z]\w+)',
  { 
    param($m) 
    $m.Groups[1].Value + ($m.Groups[2].Value.ToLower() -replace '32$')
  }
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions