/**
 * Module dependencies.
 */
var x500 = require('./x500')
  , maceLegacy = require('./mace-legacy')
  , merge = require('utils-merge')
  , DOMParser = require('xmldom').DOMParser
  , $ = require('xtraverse')


exports.parse = function(xml) {
  if (typeof xml === 'string') {
    xml = new DOMParser().parseFromString(xml);
  }
  
  // Get the attributes contained in the assertion.
  var attrs = $(xml).children('AttributeStatement', 'urn:oasis:names:tc:SAML:2.0:assertion')
                    .children('Attribute', 'urn:oasis:names:tc:SAML:2.0:assertion');
  
  // Parse the profile, utilizing various SAML attribute profiles.
  var profile = {};
  merge(profile, maceLegacy.parse(attrs));
  merge(profile, x500.parse(attrs));
  return Object.keys(profile).length ? profile : undefined;
}

@@ -206,16 +206,794 @@
 rse')%0A%0A%0A
+/**%0A * Parse attributes into a profile.%0A *%0A * This function parses attributes contained within an assertion and returns%0A * a profile object.  The profile object conforms to the contact schema%0A * specified by Portable Contacts.%0A *%0A * SAML Attribute Profiles are used to establish stanards for attribute naming,%0A * in an effort to promote interoperability.  This function supports the%0A * X.500/LDAP and MACE-Dir profiles.  Support for additional profiles can be%0A * implemented as necessary.%0A *%0A * If a profile cannot be constructed from the included attributes, %60undefined%60%0A * will be returned.%0A *%0A * References:%0A *   - %5BPortable Contacts 1.0 Draft C%5D(http://portablecontacts.net/draft-spec.html)%0A *%0A * @param %7BString%7CElement%7D xml%0A * @return %7BObject%7Cundefined%7D%0A * @api public%0A */%0A
 exports.

Document parse.