Commits

Mathias Panzenböck committed 33d4917

improved form of example

  • Participants
  • Parent commits 4a18f2a

Comments (0)

Files changed (1)

File xml-markup.js

 exports.isXmlName   = isXmlName;
 exports.isXmlNameNS = isXmlNameNS;
 
+// Example:
 if (module.parent === undefined) {(function () {
 	var xm  = new XmlMarkup(process.stdout);
-	var ex  = 'http://example.com/';
-	var ex1 = 'http://example.com/1';
-	var ex2 = 'http://example.com/2';
+	var ns1  = 'http://example.com/';
+	var ns2 = 'http://example.com/1';
+	var ns3 = 'http://example.com/2';
 
 	xm.space('\n');
 	xm.doctype('doc', 'baz', '-//foo bar//-');
 		xm.$('e0', {
 			att1: 'value',
 			att2: '"<val> "\' &',
-			att3: {uri: ex, value: 'foo'},
+			att3: {uri: ns1, value: 'foo'},
 			att4: ''});
 		xm.space('\n\t');
 		xm.$('e1');
 		xm.space('\n\t');
-		xm.$('e2', {xmlns: ex}, function () {
+		xm.$('e2', {xmlns: ns1}, function () {
 			xm.space('\n\t\t');
-			xm.$('e3', {xmlns: ex});
+			xm.$('e3', {xmlns: ns1});
 			xm.space('\n\t');
 		});
 		xm.space('\n\t');
-		xm.ns({ex: ex, ex1: ex1, '': ex2}, function () {
+		xm.ns({ns1: ns1, ns2: ns2, '': ns3}, function () {
 			xm.$('e4');
 			xm.space('\n\t');
-			xm.$('e5', {xmlns: ex});
+			xm.$('e5', {xmlns: ns1});
 			xm.space('\n\t');
-			xm.$('e6', {xmlns: ex1}, function () {
-				xm.$('e7', {attr1: {uri: ex1, value: 'bla'}});
+			xm.$('e6', {xmlns: ns2}, function () {
+				xm.$('e7', {attr1: {uri: ns2, value: 'bla'}});
 			});
 			xm.space('\n\t');
 			xm.$('e8', function () {
 				xm.space('\n\t\t');
-				xm.$('e9', {xmlns: ex2});
+				xm.$('e9', {xmlns: ns3});
 				xm.space('\n\t');
 			});
 			xm.space('\n\t');
 		xm.$('e0', {
 			att1: 'value',
 			att2: '"<val> "\' &',
-			att3: {uri: ex, value: 'foo'},
+			att3: {uri: ns1, value: 'foo'},
 			att4: ''});
 		xm.$('e1');
-		xm.$('e2', {xmlns: ex}, function () {
-			xm.$('e3', {xmlns: ex});
-			xm.$('e3', {xmlns: ex1});
+		xm.$('e2', {xmlns: ns1}, function () {
+			xm.$('e3', {xmlns: ns1});
+			xm.$('e3', {xmlns: ns2});
 		});
-		xm.ns({ex: ex, ex1: ex1, '': ex2}, function () {
+		xm.ns({ns1: ns1, ns2: ns2, '': ns3}, function () {
 			xm.$('e4');
-			xm.$('e5', {xmlns: ex});
-			xm.$('e6', {xmlns: ex1}, function () {
-				xm.$('e7', {attr1: {uri: ex1, value: 'bla'}});
+			xm.$('e5', {xmlns: ns1});
+			xm.$('e6', {xmlns: ns2}, function () {
+				xm.$('e7', {attr1: {uri: ns2, value: 'bla'}});
 			});
 			xm.$('e8', function () {
-				xm.$('e9', {xmlns: ex2});
+				xm.$('e9', {xmlns: ns3});
 			});
 		});
 		xm.$('e10', 'foo bar');
 		xm.text('<foo> "bar" baz\'s; egg bacon & spam\nbla\nbla');
 	});
-})()}
+})();}