Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mklement0 opened this issue Feb 12, 2023 · 0 comments
Open

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

mklement0 opened this issue Feb 12, 2023 · 0 comments

Comments

@mklement0
Copy link

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$')
  }
)
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

No branches or pull requests

1 participant