本文整理汇总了TypeScript中xml-writer.toString函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toString函数的具体用法?TypeScript toString怎么用?TypeScript toString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了toString函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: htmlImageFragment
// Generate HTML fragment for image.
function htmlImageFragment(image: IParserExtractedImage): string {
const xw = new XMLWriter()
xw.startElement('div')
xw.startElement('img')
xw.writeAttribute('src', image.url)
if (image.title) {
xw.writeAttribute('alt', image.title)
xw.writeAttribute('title', image.title)
}
return xw.toString()
}
开发者ID:mikl,项目名称:mordac,代码行数:15,代码来源:generator.ts
示例2: generator
export async function generator(values: IFetcherValues) {
const baseURN = 'urn:mordac:feed:'
const xw = new XMLWriter(true)
const aw = new ATOMWriter(xw)
// Generate a full, standalone, XML document.
xw.startDocument('1.0', 'utf-8')
// Generate the feed header.
aw
.startFeed(baseURN + 'atom.xml')
.writeTitle('Mordacâs RSS feed')
.writeAuthor('Scott Adams')
.writeContributor('Mordac the Preventer of Information Services')
// Generate an entry for each value.
for (const day of Object.keys(values)) {
// Generate a fake timestamp for each post, so feed readers do not
// consider them new/updated accidentally.
const date = new Date(day + 'T13:37:00Z')
const value: IParserExtractedValues = values[day]
if (value && value.largeImage && value.largeImage.url) {
aw
.startEntry(baseURN + 'entry:' + day, date, date)
.writeContent(htmlImageFragment(value.largeImage), 'html')
if (value.largeImage.title) {
aw.writeTitle(value.largeImage.title)
}
aw.endEntry()
}
}
aw.endFeed()
xw.endDocument()
await fs.promises.writeFile(outputDir + '/atom.xml', xw.toString())
}
开发者ID:mikl,项目名称:mordac,代码行数:41,代码来源:generator.ts
示例3: dumpXml
export function dumpXml(
node: BaseNode,
options: any
) {
const addressSpace = node.addressSpace;
const namespace = node.namespace as NamespacePrivate;
// make a first visit so that we determine which node to output and in which order
const nodesToVisit: any = {};
const dependency = constructNamespaceDependency(namespace);
const translationTable = constructNamespaceTranslationTable(dependency);
const xw = new XMLWriter(true);
xw.translationTable = translationTable;
visitUANode(node, nodesToVisit, false);
xw.startDocument({ encoding: "utf-8" });
xw.startElement("UANodeSet");
xw.writeAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema-instance");
xw.writeAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
xw.writeAttribute("Version", "1.02");
xw.writeAttribute("LastModified", (new Date()).toISOString());
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2011/03/UANodeSet.xsd");
buildUpAliases(node, xw, nodesToVisit);
writeAliases(xw, nodesToVisit.aliases);
for (const el of nodesToVisit.elements) {
el.dumpXML(xw);
}
xw.endElement();
xw.endDocument();
return xw.toString();
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:39,代码来源:nodeset_to_xml.ts
示例4: renderToString
export function renderToString(element) {
const writer = new XMLWriter(true);
renderToXmlWriter(element, writer);
return writer.toString();
}
开发者ID:luggage66,项目名称:jsx-xsl-fo,代码行数:6,代码来源:implementation.ts
示例5: function
UANamespace.prototype.toNodeset2XML = function(this: UANamespace) {
const dependency = constructNamespaceDependency(this);
const translationTable = constructNamespaceTranslationTable(dependency);
const xw = new XMLWriter(true);
xw.translationTable = translationTable;
xw.startDocument({ encoding: "utf-8", version: "1.0" });
xw.startElement("UANodeSet");
xw.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
xw.writeAttribute("xmlns:uax", "http://opcfoundation.org/UA/2008/02/Types.xsd");
xw.writeAttribute("xmlns", "http://opcfoundation.org/UA/2011/03/UANodeSet.xsd");
// xx xw.writeAttribute("Version", "1.02");
// xx xw.writeAttribute("LastModified", (new Date()).toISOString());
// ------------- Namespace Uris
xw.startElement("NamespaceUris");
// xx const namespaceArray = namespace.addressSpace.getNamespaceArray();
for (const depend of dependency) {
xw.startElement("Uri");
xw.text(depend.namespaceUri);
xw.endElement();
}
xw.endElement();
// ------------- Namespace Uris
xw.startElement("Models");
xw.endElement();
const s: any = {};
for (const node of _.values(this._nodeid_index)) {
buildUpAliases(node, xw, s);
}
writeAliases(xw, s.aliases);
xw.visitedNode = {};
// -------------- writeReferences
xw.writeComment("ReferenceTypes");
const referenceTypes = _.values(this._referenceTypeMap).sort(sortByBrowseName);
for (const referenceType of referenceTypes) {
dumpReferenceType(xw, referenceType);
}
// -------------- ObjectTypes
xw.writeComment("ObjectTypes");
const objectTypes = _.values(this._objectTypeMap).sort(sortByBrowseName);
// xx xw.writeComment(" "+ objectTypes.map(x=>x.browseName.name.toString()).join(" "));
for (const objectType of objectTypes) {
if (!xw.visitedNode[_hash(objectType)]) {
objectType.dumpXML(xw);
}
}
// -------------- VariableTypes
xw.writeComment("VariableTypes");
const variableTypes = _.values(this._variableTypeMap).sort(sortByBrowseName);
// xx xw.writeComment("ObjectTypes "+ variableTypes.map(x=>x.browseName.name.toString()).join(" "));
for (const variableType of variableTypes) {
if (!xw.visitedNode[_hash(variableType)]) {
variableType.dumpXML(xw);
}
}
// -------------- Any thing else
xw.writeComment("Other Nodes");
const nodes = _.values(this._nodeid_index).sort(sortByBrowseName);
// xx xw.writeComment(" "+ nodes.map(x=>x.browseName.name.toString()).join(" "));
for (const node of nodes) {
if (!xw.visitedNode[_hash(node)]) {
node.dumpXML(xw);
}
}
xw.endElement();
xw.endDocument();
return xw.toString();
};
开发者ID:node-opcua,项目名称:node-opcua,代码行数:81,代码来源:nodeset_to_xml.ts
注:本文中的xml-writer.toString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论