SSE4E GPError GPSystem ByteString ByteBuffer TLV TLVList Card Atr Key Crypto Application GPApplication GPSecDomain ASN1 CardFile IsoSecureChannel ApplFactory GPXML JsScript CardSim X509 CRL KeyStore CMSSignedData CMSGenerator XMLSignature OCSPQuery LDAP SOAP URLConnection PKCS11Provider PKCS11Session PKCS11Object OutlineNode OpenSCDP |
GPXML - Reference Documentation
Core XML parser for Global Platform Profiles. XML profiles are deserialized into a tree of ECMAScript objects. Child elements are created as a property under the parent object with the name of the XML element. Attributes are created as a property with the same name and of type String. Namespaces are silently ignored (e.g. gp:Key is stored as property Key). If an element contains a value, then the characters are collected into the elementValue property. If an element contains CDATA, then the characters are collected into the elementValue property. If a Script element is found and there is no explicit script definition using defineScriptElement(), then the content of the element is evaluated as an ECMAScript function without parameter and stored under the Script property of the parent element. If a parent element defines the arrayElement and arrayIndex attributes, then client elements with the same name are deserialized as an array. Index of MethodsConstructorPrototypeGPXML() DescriptionCreate a parser object to parse the specified XML file. The actual parsing is done using the GPXML.prototype.parse() method. Exceptions
Examplevar parser = new GPXML(); defineArrayElement()PrototypedefineArrayElement(String path, String arrayElement) defineArrayElement(String path, String arrayElement, String arrayIndex) DescriptionDefine which XML child nodes must be deserialized as JavaScript array. This has the same effect as specifying an arrayElement and arrayIndex attribute at an XML node. Multiple values for arrayElement and arrayIndex can be specified in a comma separated list. The array can be either indexed by integer ("#") or using an attribute as key value. Arguments
Return
Exceptions
Exampleparser.defineArrayElement("/Root/Child3/Child4", "Array1"); parser.defineArrayElement("/Root/Child3/Child5", "Array1", "name"); parser.defineArrayElement("/Root/Child3/Child6", "Array1,Array2", "#,name"); defineScriptElement()PrototypedefineScriptElement(String path) defineScriptElement(String path, Boolean asFunction) DescriptionDefine which XML nodes are to be interpreted as script code. By default all <Script> elements are parsed as script code. Arguments
Return
Exceptions
Exampleparser.defineScriptElement("/Root/AnonymousFunction/Script"); parser.defineScriptElement("/Root/Function/Script", true); parser.defineScriptElement("/Root/FunctionNoScript", true); parser.defineScriptElement("/Root/Script", false); parser.defineScriptElement("/Root/PlainScript", false); parse()PrototypeObject parse(String filename) Object parse(ByteString file) DescriptionParse the XML formatted file specified by filename and create a tree of ECMAScript objects. The file can be provided as ByteString. If the ByteString starts with 1F8B, then it is treated as GZIP file. The parse() method without arguments can be used with an instance object, the other two variants are static methods. Arguments
Return
Exceptions
Example// Dynamic variant var profile = parser.parse("parsertest2.xml"); dumpxml(profile, ""); assert(profile); assert(profile.rootAttr1 == "rootAttr1"); assert(profile.rootAttr2 == "rootAttr2"); assert(profile.Child1); assert(profile.Child1.child1Attr1 == "child1Attr1"); assert(profile.Child1.child1Attr2 == "child1Attr2"); assert(profile.Child2); assert(profile.Child2.child2Attr1 == "child2Attr1"); assert(profile.Child2.elementValue == "child2Value"); assert(profile.Child3); assert(profile.Child3.Child4); assert(profile.Child3.Child4.Array1); assert(profile.Child3.Child4.Array1.length == 3); assert(profile.Child3.Child4.Array1[0].name == "a1"); assert(profile.Child3.Child4.Array1[1].arrayAttr1 == "arrayAttr1"); assert(profile.Child3.Child4.Array1[2].name == "a2"); assert(profile.Child3); assert(profile.Child3.Child5); assert(profile.Child3.Child5.Array1); assert(profile.Child3.Child5.Array1["a1"].name == "a1"); assert(profile.Child3.Child5.Array1["a2"].arrayAttr2 == "arrayAttr2"); assert(profile.Child3.Child5.Array1["a3"].name == "a3"); assert(profile.Child3); assert(profile.Child3.Child6); assert(profile.Child3.Child6.Array1); assert(profile.Child3.Child6.Array1[0].name == "a1"); assert(profile.Child3.Child6.Array1[1].arrayAttr1 == "arrayAttr1"); assert(profile.Child3.Child6.Array1[2].name == "a2"); assert(profile.Child3.Child6.Array2); assert(profile.Child3.Child6.Array2["b1"].name == "b1"); assert(profile.Child3.Child6.Array2["b2"].arrayAttr5 == "arrayAttr5"); assert(profile.Child3.Child6.Array2["b3"].name == "b3"); assert(profile.AnonymousFunction.Script instanceof Function); globalResult = ""; profile.AnonymousFunction.Script(); assert(globalResult == "globalResult"); assert(profile.Function.Script instanceof Function); assert(profile.Function.Script(1, 2) == 3); assert(profile.FunctionNoScript.Script instanceof Function); assert(profile.FunctionNoScript.Script(1, 2) == 3); assert(profile.PlainScript.Script instanceof JsScript); profile.PlainScript.Script.execute(this); assert(f(1 ,2) == 3); // Static variant var profile = GPXML.parse("parsertest.xml"); dumpxml(profile, ""); assert(profile); assert(profile.rootAttr1 == "rootAttr1"); assert(profile.rootAttr2 == "rootAttr2"); assert(profile.Child1); assert(profile.Child1.child1Attr1 == "child1Attr1"); assert(profile.Child1.child1Attr2 == "child1Attr2"); assert(profile.Child2); assert(profile.Child2.child2Attr1 == "child2Attr1"); assert(profile.Child2.elementValue == "child2Value"); assert(profile.Child3); assert(profile.Child3.Child4); assert(profile.Child3.Child4.Array1); assert(profile.Child3.Child4.Array1.length == 3); assert(profile.Child3.Child4.Array1[0].name == "a1"); assert(profile.Child3.Child4.Array1[1].arrayAttr1 == "arrayAttr1"); assert(profile.Child3.Child4.Array1[2].name == "a2"); assert(profile.Child3); assert(profile.Child3.Child5); assert(profile.Child3.Child5.Array1); assert(profile.Child3.Child5.Array1["a1"].name == "a1"); assert(profile.Child3.Child5.Array1["a2"].arrayAttr2 == "arrayAttr2"); assert(profile.Child3.Child5.Array1["a3"].name == "a3"); assert(profile.AnonymousFunction.Script instanceof Function); globalResult = ""; profile.AnonymousFunction.Script(); assert(globalResult == "globalResult"); assert(profile.Function.Script instanceof Function); assert(profile.Function.Script(1, 2) == 3); parseApplicationProfile()PrototypeObject parse(String filename) DescriptionParse the XML formatted application profile specified by filename and create a tree of ECMAScript objects. The elements Key, DataElement, Function and ScriptFragment are deserialized as arrays. Arguments
Return
Exceptions
Example// var profile = GPXML.parseApplicationProfile("appl.xml"); // dumpxml(profile, ""); © Copyright 2003 - 2010 CardContact Software & System Consulting, Minden, Germany |