Skip to content

Simplified Mapping Style

Alexey Valikov edited this page Feb 27, 2015 · 6 revisions

Simplified Mapping Style

Simplified mapping style differs from the standard mapping style in the way the root element and element references are mapped. Instead of using { name : <elementName>, value: <elementValue> }, simplified mapping style just does { <elementName> : <elementValue> }. Whereas the <elementName> is made string using the namespace prefix mapping.

Root element

Example.

XML:

<value attribute="check">test</value>

JS:

{
	value : {
		value : "test",
		attribute : "check"
	}
}

Elements

Element reference property

Fragment of the mapping:

{
	name: 'base',
	collection: true,
	elementName: 'base',
	typeInfo: 'Zero.BaseType',
	type: 'elementRef'
}

XML:

<elementRef><base><alpha>one</alpha><beta>2</beta></base></elementRef>

JS:

{
	base : [ {
		base : {
			alpha : "one",
			beta : [ 2 ]
		}
	} ]
}

Element references property

Fragment of the mapping:

{
	name: 'alphaOrBeta',
	collection: true,
	elementTypeInfos: [{
		elementName: 'beta',
		typeInfo: 'Zero.ValueType'
	}, {
		elementName: 'alpha',
		typeInfo: 'Zero.ValueType'
	}],
	type: 'elementRefs'
}

XML:

<elementRefs><alpha>one</alpha><beta>2</beta></elementRefs>

JS:

{
	alphaOrBeta : [ {
		alpha : {
			value : "one"
		}
	}, {
		beta : {
			value : "2"
		}
	} ]
}

Any element property

Fragment of the mapping:

{
	name: 'any',
	domAllowed: true,
	typedObjectAllowed: true,
	type: 'anyElement'
}

XML:

<anyElementLax><string>test</string></anyElementLax>

JS:

{
	any : {
		string : "test"
	}
}
Clone this wiki locally