当前位置: 首页>>代码示例>>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;未经允许,请勿转载。