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

Function transformSourceXml

packages/universal-xml-plugin/lib/source.ts:32–50  ·  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 // the ios <AppiumAUT> root deliberately gets no index path: the XCUITest driver leaves that
38 // wrapper out of the hierarchy it runs queries against, so index paths have to be relative to
39 // the node below it. the android <hierarchy> root does carry an index attribute and is part of
40 // the queried hierarchy, so it keeps its index path
41 const xmlObj = singletonXmlParser().parse(xmlStr);
42 const unknowns = transformNode(xmlObj, platform, {
43 metadata,
44 addIndexPath,
45 parentPath: '',
46 });
47 let transformedXml = singletonXmlBuilder().build(xmlObj).trim();
48 transformedXml = `<?xml version="1.0" encoding="UTF-8"?>\n${transformedXml}`;
49 return {xml: transformedXml, unknowns};
50}
51
52/**
53 * Gets the universal node name for a platform-specific node name

Callers 4

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

Calls 2

transformNodeFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected