當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript xmlbuilder.create函數代碼示例

本文整理匯總了TypeScript中xmlbuilder.create函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript create函數的具體用法?TypeScript create怎麽用?TypeScript create使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了create函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: toAtomString

  public static toAtomString(releases: Release[], {
      link = "https://github.com/Gerhut/releases-tracker",
      title = "Releases Tracker",
    } = {}) {
    const feedElement = xmlbuilder.create("feed", { encoding: "utf-8" });
    feedElement.attribute("xmlns", "http://www.w3.org/2005/Atom");
    feedElement.element("id")
      .text(link);
    feedElement.element("title")
      .text(title);
    feedElement.element("link")
      .attribute("rel", "self")
      .attribute("type", "application/atom+xml")
      .attribute("href", link);

    const sortedReleases = releases.filter((release) => release.id !== undefined);
    sortedReleases.sort((a, b) => (b.updated || 0).valueOf() - (a.updated || 0).valueOf());

    const latestRelease = sortedReleases[0];
    if (latestRelease !== undefined && latestRelease.updated !== undefined) {
      feedElement.element("updated")
        .text(latestRelease.updated.toISOString());
    } else {
      feedElement.element("updated")
        .text(new Date().toISOString());
    }

    for (const release of sortedReleases) {
      feedElement.importDocument(release.toAtomEntryElement());
    }

    return feedElement.end({
      pretty: process.env.NODE_ENV !== "production",
    });
  }
開發者ID:Gerhut,項目名稱:releases-tracker,代碼行數:35,代碼來源:Release.ts

示例2: buildXML

export function buildXML() {
	let convertToXMLObj = (icon: IconInfo): IconXML => {
		return {
			'@id': icon.name,
			'unicode': {
				'#text': icon.unicode
			}
		};
	};

	let xmlObj = {
		style: {
			solid: {
				icon: JSONSource.solid.map(convertToXMLObj)
			},
			regular: {
				icon: JSONSource.regular.map(convertToXMLObj)
			},
			brands: {
				icon: JSONSource.brands.map(convertToXMLObj)
			}
		}
	};
	let xmlStr = xmlBuilder.create(xmlObj, { version: '1.0', encoding: 'UTF-8' })
		.end({
			pretty: true,
			indent: '\t'
		});

	return createStream(`${filename}.xml`, xmlStr)
		.pipe(plumber())
		.pipe(gulp.dest('character-list'));
}
開發者ID:gluons,項目名稱:Font-Awesome-Icon-Chars,代碼行數:33,代碼來源:gulpfile.ts

示例3:

				).then((obj:any) => {
					var Association = obj.Assoc;
					var AssociationSet = obj.AssocSet;
					var xmlBuilder = builder.create(
						{
							"edmx:Edmx": {
								"@xmlns:edmx": "http://schemas.microsoft.com/ado/2007/06/edmx",
								"@xmlns:m": "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata",
								"@Version": "1.0",
								"edmx:DataServices": {
									"@m:DataServiceVersion": "2.0",
									"Schema": {
										"@xmlns": "http://schemas.microsoft.com/ado/2008/09/edm",
										"@Namespace": constants.ODATA_NAMESPACE,
										EntityType,
										Association,
										"EntityContainer": {
											"@Name": constants.ODATA_NAMESPACE,
											"@m:IsDefaultEntityContainer": "true",
											EntitySet,
											AssociationSet
										}
									}
								}
							}
						}, {version: '1.0', encoding: 'UTF-8'}
					).end({pretty: true});
					logger.trace('metadata xml build');
					resolve(xmlBuilder);
				});
開發者ID:draschke,項目名稱:n-odata-server,代碼行數:30,代碼來源:metadata.ts

示例4: buildXML

export async function buildXML() {
	const iconSource = await getSource();
	const { icons } = iconSource;
	const xmlObj = {
		icons: {
			icon: []
		}
	};

	for (const icon of icons) {
		xmlObj.icons.icon.push({
			'@id': icon.id,
			'#text': icon.unicode
		});
	}

	const xmlStr = xmlBuilder
		.create(xmlObj, {
			encoding: 'UTF-8'
		})
		.end({
			pretty: true,
			indent: '\t'
		});

	return createStream('character-list.xml', xmlStr)
		.pipe(plumber())
		.pipe(dest('character-list'));
}
開發者ID:gluons,項目名稱:material-design-icon-chars,代碼行數:29,代碼來源:gulpfile.ts

示例5: buildMetadata

function buildMetadata(models: any,nameSpace: string): any {

    let entitesType = [];
    let EntitiesContainer = [];
    let container = {
        "EntityContainer": {
            "@Name": "Context",
            "EntitySet": []
        }
    }; 
    for (let model in models) {
        entitesType.push(getEntitiesType(models[model],nameSpace));
        getEntitiesContainer(model,nameSpace,container);
    }
    EntitiesContainer.push( container.EntityContainer);
    let xmlRoot = builder.create('edmx:Edmx');
    
    let objMetadata = {
        "@xmlns:edmx": "http://docs.oasis-open.org/odata/ns/edmx",
        "@Version": "4.0",
        "edmx:DataServices": {
            "Schema": {
                "@xmlns": "http://docs.oasis-open.org/odata/ns/edm",
                "@Namespace": nameSpace,
                "EntityType": entitesType,
                //  "ComplexType" : comType,
                "EntityContainer": EntitiesContainer

            }
        }

    };

    var ele = xmlRoot.ele(objMetadata);
    return ele.end({ pretty: true });

}
開發者ID:MSeifAllah,項目名稱:MDR-METADATA-SWAGGER,代碼行數:37,代碼來源:metadata.ts

示例6: toAtomEntryElement

  public toAtomEntryElement() {
    if (this.id === undefined) {
      throw new TypeError(`${this}'s id is undefined.`);
    }
    if (this.title === undefined) {
      throw new TypeError(`${this}'s title is undefined.`);
    }
    if (this.author === undefined) {
      throw new TypeError(`${this}'s author is undefined.`);
    }
    if (this.link === undefined) {
      throw new TypeError(`${this}'s link is undefined.`);
    }
    if (this.updated === undefined) {
      throw new TypeError(`${this}'s updated is undefined.`);
    }

    const entryElement = xmlbuilder.create("entry");
    entryElement.element("id")
      .text(this.id);
    entryElement.element("title")
      .text(this.title);
    entryElement.element("author")
      .element("name")
        .text(this.author);
    entryElement.element("link")
      .attribute("rel", "alternate")
      .attribute("type", "text/html")
      .attribute("href", this.link);
    entryElement.element("updated")
      .text(this.updated.toISOString());
    entryElement.element("content")
      .text(this.title);

    return entryElement;
  }
開發者ID:Gerhut,項目名稱:releases-tracker,代碼行數:36,代碼來源:Release.ts

示例7: sitemap

	/**
	 * Prints the sitemap for a site running vpdb-website.
	 *
	 * @see GET /v1/sitemap
	 * @param {Context} ctx
	 * @returns {Promise<void>}
	 */
	public async sitemap(ctx: Context) {

		if (!ctx.query.url) {
			throw new ApiError('Must specify website URL as "url" parameter.').status(400);
		}
		const parsedUrl = parse(ctx.query.url);
		if (!parsedUrl.host || !parsedUrl.protocol) {
			throw new ApiError('URL must contain at least protocol and host name.').status(400);
		}
		if (parsedUrl.search || parsedUrl.hash) {
			throw new ApiError('URL must not contain a search query or hash').status(400);
		}

		const webUrl = format(parsedUrl);

		const rootNode = builder
			.create('urlset', { version: '1.0', encoding: 'UTF-8' })
			.att('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9')
			.att('xmlns:image', 'http://www.google.com/schemas/sitemap-image/1.1');

		// static urls
		rootNode.ele('url').ele('loc', webUrl);
		rootNode.ele('url').ele('loc', webUrl + 'games');
		rootNode.ele('url').ele('loc', webUrl + 'releases');
		rootNode.ele('url').ele('loc', webUrl + 'about');
		rootNode.ele('url').ele('loc', webUrl + 'rules');
		rootNode.ele('url').ele('loc', webUrl + 'faq');
		rootNode.ele('url').ele('loc', webUrl + 'legal');
		rootNode.ele('url').ele('loc', webUrl + 'privacy');

		// releases
		const releases = await state.models.Release.find({})
			.populate('_game')
			.populate('versions.files._playfield_image')
			.populate('authors._user')
			.exec();
		releases.forEach(release => {
			const game = release._game as GameDocument;
			let fsImage: FileDocument;
			let dtImage: FileDocument;
			for (const version of release.versions) {
				const tableFiles = version.files.filter(file => file._playfield_image && (file._playfield_image as FileDocument).metadata);
				for (const file of tableFiles) {
					const playfieldImage = file._playfield_image as FileDocument;
					if (playfieldImage.metadata.size.width > playfieldImage.metadata.size.height) {
						dtImage = playfieldImage;
					} else {
						fsImage = playfieldImage;
					}
				}
			}
			const authors = release.authors.map(author => (author._user as UserDocument).name).join(', ');
			const url = rootNode.ele('url');
			url.ele('loc', webUrl + 'games/' + game.id + '/releases/' + release.id);
			if (fsImage) {
				const img = url.ele('image:image');
				img.ele('image:loc', fsImage.getUrl(ctx.state, fsImage.getVariation('full')));
				img.ele('image:caption', 'Portrait playfield for ' + game.title + ', ' + release.name + ' by ' + authors + '.');
			}
			if (dtImage) {
				const img = url.ele('image:image');
				img.ele('image:loc', dtImage.getUrl(ctx.state, dtImage.getVariation('full')));
				img.ele('image:caption', 'Landscape playfield for ' + game.title + ', ' + release.name + ' by ' + authors + '.');
			}
		});

		// games
		const games = await state.models.Game.find({}).exec();
		for (const game of games) {

			const url = rootNode.ele('url');
			url.ele('loc', webUrl + 'games/' + game.id);

			const media = await state.models.Medium.find({ '_ref.game': game._id }).populate({ path: '_file' }).exec();
			for (const medium of media) {
				const file = medium._file as FileDocument;
				switch (medium.category) {
					case 'wheel_image': {
						const img = url.ele('image:image');
						img.ele('image:loc', file.getUrl(ctx.state, file.getVariation('medium-2x')));
						img.ele('image:caption', 'Logo for ' + game.title);
						break;
					}
					case 'backglass_image': {
						const img = url.ele('image:image');
						img.ele('image:loc', file.getUrl(ctx.state, file.getVariation('full')));
						img.ele('image:caption', 'Backglass for ' + game.title);
						break;
					}
				}
			}
		}
		ctx.status = 200;
//.........這裏部分代碼省略.........
開發者ID:freezy,項目名稱:node-vpdb,代碼行數:101,代碼來源:misc.api.ts

示例8: function

 res.send = function(...data) {
   const obj = {};
   obj[xmlRoot] = data[0];
   data[0] = xmlbuilder.create(obj).end();
   originalSend.apply(res, data);
 };
開發者ID:yruan,項目名稱:inceptum,代碼行數:6,代碼來源:ContentNegotiationMiddleware.ts


注:本文中的xmlbuilder.create函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。