(
xmlStr: string,
platform: string,
{metadata = {} as TransformMetadata, addIndexPath = false}: TransformSourceXmlOptions = {},
)
| 30 | * @returns Promise resolving to transformed XML and unknown nodes/attributes |
| 31 | */ |
| 32 | export 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 |
no test coverage detected