MCPcopy Create free account
hub / github.com/appium/appium / transformSourceXml

Function transformSourceXml

packages/universal-xml-plugin/lib/source.ts:32–49  ·  view source on GitHub ↗
(
  xmlStr: string,
  platform: string,
  {metadata = {} as TransformMetadata, addIndexPath = false}: TransformSourceXmlOptions = {},
)

Source from the content-addressed store, hash-verified

30 * @returns Promise resolving to transformed XML and unknown nodes/attributes
31 */
32export async function transformSourceXml(
33 xmlStr: string,
34 platform: string,
35 {metadata = {} as TransformMetadata, addIndexPath = false}: TransformSourceXmlOptions = {},
36): Promise<{xml: string; unknowns: NodesAndAttributes}> {
37 // first thing we want to do is modify the ios source root node, because it doesn't include the
38 // necessary index attribute, so we add it if it's not there
39 xmlStr = xmlStr.replace('<AppiumAUT>', '<AppiumAUT index="0">');
40 const xmlObj = singletonXmlParser().parse(xmlStr);
41 const unknowns = transformNode(xmlObj, platform, {
42 metadata,
43 addIndexPath,
44 parentPath: '',
45 });
46 let transformedXml = singletonXmlBuilder().build(xmlObj).trim();
47 transformedXml = `<?xml version="1.0" encoding="UTF-8"?>\n${transformedXml}`;
48 return {xml: transformedXml, unknowns};
49}
50
51/**
52 * Gets the universal node name for a platform-specific node name

Callers 4

getPageSourceMethod · 0.90
mainFunction · 0.90
xpath.spec.tsFile · 0.90
source.spec.tsFile · 0.90

Calls 1

transformNodeFunction · 0.85

Tested by

no test coverage detected