Skip to content

Standard Mapping Style

highsource edited this page Feb 27, 2015 · 20 revisions

Standard Mapping Style

Standard mapping style is a mapping style used by Jsonix by default.

Root element

Example.

XML:

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

JS:

{
	name : { localPart : "value", namespaceURI : "", prefix : "" },
	value : ...
}

Character content

Value property

Example.

Fragment of the mapping:

{
	name: 'value',
	typeInfo: 'String',
	type: 'value'
}

XML:

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

JS:

{
	value : "test"
}

# Attributes

## Attribute property

Example.

Fragment of the mapping:

```javascript
{
	name: 'string',
	attributeName: 'string',
	type: 'attribute'
}

XML:

<attribute string="zero" integers="1 2">test</attribute>

JS:

{
	string : "zero"
}

Any attribute property

Example.

Fragment of the mapping:

{
	name: 'otherAttributes',
	type: 'anyAttribute'
}

XML:

<anyAttribute a="a" b="b">test</anyAttribute>

JS:

{
	otherAttributes : {
		a : "a",
		b : "b"
	}
}

Elements

Element property

Fragment of the mapping:

{
	type: 'element',
	name: 'element',
	elementName: 'element',
	typeInfo: 'String'
}

XML:

<element><element>one</element></element>

JS:

{
	element : "one"
}

Elements property

Fragment of the mapping:

{
	name: 'stringOrInteger',
	collection: true,
	elementTypeInfos: [{
		elementName: 'string',
		typeInfo: 'String'
	}, {
		elementName: 'integer',
		typeInfo: 'Integer'
	}],
	type: 'elements'
}

XML:

<elements><string>one</string><integer>2</integer></elements>

JS:

{
	stringOrInteger : [ "one", 2 ]
}

Element map property

Fragment of the mapping:

TODO

XML:

TODO

JS:

TODO

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 : [ {
		name : { localPart : "base", namespaceURI : "", prefix : "" },
		value : {
			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 : [ {
		name : { localPart : "alpha", namespaceURI : "", prefix : "" },
		value : {
			value : "one"
		}
	}, {
		name : { localPart : "beta", namespaceURI : "", prefix : "" },
		value : {
			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 : {
		name : { localPart : "string", namespaceURI : "", prefix : "" },
		value : "test"
	}
}
Clone this wiki locally