Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6355503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:46:40+00:00 2026-05-24T22:46:40+00:00

1. Background We have a application that depends on several XML configuration files. The

  • 0

1. Background

We have a application that depends on several XML configuration files. The XML files define things like connection settings, polling frequencies, multiple user accounts (using XSD nested types/sequences) etc.

I have the XSD schema for these XML files. Small excerpt below:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="FooExch"  type="CConfigFooType"/>

<xs:complexType name="CConfigFooType">
  <xs:sequence>
    <xs:element name="_appID" type="xs:string"/>
    ...
    <xs:element name="_logins" type="FooLoginsType" maxOccurs="unbounded"/>
    <xs:element name="_passwords" type="FooPasswordType" maxOccurs="unbounded"/>
    ...
  </xs:sequence>
</xs:complexType>

<xs:complexType name="FooLoginsType">
  <xs:sequence>
    <xs:element name="_name" type="xs:string"/>
    <xs:element name="_adapterID" type="xs:int"/>
    <xs:element name="_FooLogins" type="FooAccountType" maxOccurs="unbounded"/>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="FooAccountType">
  <xs:sequence>
    <xs:element name="_FooAccount" type="xs:string"/>
    <xs:element name="_mktFeed" type="xs:int"/>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="FooPasswordType">
  <xs:sequence>
    <xs:element name="_name" type="xs:string"/>
    <xs:element name="_password" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

</xs:schema>

2. Objective

Our aim is to make it easier for users to tweak or add to settings.

I’d like to offer a script that took a YAML file, and based on the XSD outputted a XML configuration (with default fallbacks for missing values, perhaps in a default.yaml file.).

We’d also need the ability to “append” a YAML to the XML – as in, a user could have a YAML which just defines their user account, and we’d import this to the existing list of user accounts in an existing XML file.

3. Approach

So far I’m using GenerateDS (http://www.rexx.com/~dkuhlman/generateDS.html) to generate a Python wrapper from the XSD.

Using that, I can create a Python object representing the XML schema, then export them to XML.

The issue now is how do I go from a YAML to the XML?

Ideally, I’d like a generic loop that just ran over each value, and added it to the Python representation.

My initial thought was to use getattr(config_wrapper, "yaml_name") = yaml_value and iterate over each value in the YAML, then catch AttributeError for anything that wasn’t in the XSD.

My first question – are any issues to this approach, or is there perhaps a more Pythonic/cleaner way of doing this? Is there a smarter way of tackling this question?

My second question is – with the above part of the XSD, we need to have nested logins, with username/passwords. I know PyYAML offers nested collections, but I’m still not quite sure how this would tie into GenerateDS, or how I could make it generic enough to work reliable.

Cheers,
Victor

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:46:41+00:00Added an answer on May 24, 2026 at 10:46 pm

    I’d avoid the XSD, sounds like a lot of bureaucracy for little gain.

    1. Create YAML file with same hierarchy as the XML file.
    2. Load file with pyyaml
    3. Loop over result creating the equivalent tree in elementtree.
    4. Write tree to XML file
    5. Send XML to system, when it complains, fix YAML and return to step 2.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an application that downloads some files in the background. Our application pops
Background: We have a client/server application that uses a persistent connection to the server.
Background: we have an application that generates reports from HTML (that may or may
Background: We have an application that has been in the works for over a
I have an application that will mainly operate in the background. I want certain
Some background: we have a windows application (c#) that locate in the system try.
Scenario I have a background worker in my application that runs off and does
Say I have a third party Application that does background work, but prints out
Background Currently, I am working on a Rails application. I have different products that
Background I have an application written in native C++ over the course of several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.