Convertendo um arquivo de esquema XML do Cognos em XML usando o código Javascript
Encontrei muitos "conversores" on-line que farão isso por você, mas não consegui encontrar nenhum código-fonte que possa implementar facilmente. Fiquei me perguntando se alguém seria tão gentil em me fornecer sugestões ou até mesmo me fornecer um código que fará essa tarefa por mim. Estou tentando converter para XML, para que seja mais fácil analisa
Estou tentando converter isso (esquema XML do Cognos) ...
<?xml version="1.0" encoding="utf-8" ?>
- <dataset xmlns="http://developer.cognos.com/schemas/xmldata/1/" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
- <!--
<dataset
xmlns="http://developer.cognos.com/schemas/xmldata/1/"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://developer.cognos.com/schemas/xmldata/1/ xmldata.xsd"
>
-->
- <metadata>
<item name="ROOT_NODE_ID" type="xs:decimal" precision="38" />
<item name="LEVEL1_ID" type="xs:string" length="2002" />
<item name="LEVEL1_NAME" type="xs:string" length="512" />
<item name="LEVEL2_ID" type="xs:string" length="2002" />
<item name="LEVEL2_NAME" type="xs:string" length="512" />
<item name="LEVEL3_ID" type="xs:string" length="2002" />
<item name="LEVEL3_NAME" type="xs:string" length="512" />
<item name="LEVEL4_ID" type="xs:string" length="2002" />
<item name="LEVEL4_NAME" type="xs:string" length="512" />
<item name="LEVEL5_ID" type="xs:string" length="2002" />
<item name="LEVEL5_NAME" type="xs:string" length="512" />
<item name="LEVEL6_ID" type="xs:string" length="2002" />
<item name="LEVEL6_NAME" type="xs:string" length="512" />
<item name="LEVEL7_ID" type="xs:string" length="2002" />
<item name="LEVEL7_NAME" type="xs:string" length="512" />
<item name="LEVEL8_ID" type="xs:string" length="2002" />
<item name="LEVEL8_NAME" type="xs:string" length="512" />
<item name="LEVEL9_ID" type="xs:string" length="2002" />
<item name="LEVEL9_NAME" type="xs:string" length="512" />
<item name="LEVEL10_ID" type="xs:string" length="2002" />
<item name="LEVEL10_NAME" type="xs:string" length="512" />
</metadata>
- <data>
- <row>
<value>5</value>
<value>5</value>
<value>Global Root</value>
<value>41</value>
<value>Company</value>
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
</row>
- <row>
<value>5</value>
<value>5</value>
<value>Global Root</value>
<value>41</value>
<value>Company</value>
<value>101590</value>
<value>Customer</value>
<value>101591</value>
<value>Customer -All Sites</value>
<value>125083</value>
<value>Site 1</value>
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
</row>
</data>
</dataset>
Para isso (XML) ....
<?xml version="1.0" encoding="UTF-8"?>
<rows>
<row>
<ROOT_NODE_ID>5</ROOT_NODE_ID>
<LEVEL1_ID>5</LEVEL1_ID>
<LEVEL1_NAME>Global Root</LEVEL1_NAME>
<LEVEL2_ID>41</LEVEL2_ID>
<LEVEL2_NAME>Company</LEVEL2_NAME>
<LEVEL3_ID></LEVEL3_ID>
<LEVEL3_NAME></LEVEL3_NAME>
<LEVEL4_ID></LEVEL4_ID>
<LEVEL4_NAME></LEVEL4_NAME>
<LEVEL5_ID></LEVEL5_ID>
<LEVEL5_NAME></LEVEL5_NAME>
<LEVEL6_ID></LEVEL6_ID>
<LEVEL6_NAME></LEVEL6_NAME>
<LEVEL7_ID></LEVEL7_ID>
<LEVEL7_NAME></LEVEL7_NAME>
<LEVEL8_ID></LEVEL8_ID>
<LEVEL8_NAME></LEVEL8_NAME>
<LEVEL9_ID></LEVEL9_ID>
<LEVEL9_NAME></LEVEL9_NAME>
<LEVEL10_ID></LEVEL10_ID>
<LEVEL10_NAME></LEVEL10_NAME>
</row>
<row>
<ROOT_NODE_ID>5</ROOT_NODE_ID>
<LEVEL1_ID>5</LEVEL1_ID>
<LEVEL1_NAME>Global Root</LEVEL1_NAME>
<LEVEL2_ID>41</LEVEL2_ID>
<LEVEL2_NAME>Company</LEVEL2_NAME>
<LEVEL3_ID>101590</LEVEL3_ID>
<LEVEL3_NAME>Customer</LEVEL3_NAME>
<LEVEL4_ID>101591</LEVEL4_ID>
<LEVEL4_NAME>Customer -All Sites</LEVEL4_NAME>
<LEVEL5_ID>125083</LEVEL5_ID>
<LEVEL5_NAME>Site 1</LEVEL5_NAME>
<LEVEL6_ID></LEVEL6_ID>
<LEVEL6_NAME></LEVEL6_NAME>
<LEVEL7_ID></LEVEL7_ID>
<LEVEL7_NAME></LEVEL7_NAME>
<LEVEL8_ID></LEVEL8_ID>
<LEVEL8_NAME></LEVEL8_NAME>
<LEVEL9_ID></LEVEL9_ID>
<LEVEL9_NAME></LEVEL9_NAME>
<LEVEL10_ID></LEVEL10_ID>
<LEVEL10_NAME></LEVEL10_NAME>
</row>
</rows>