[Destructive, Use Caution] Copy tags and its child elements from specific XML schema

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Copy tags and its child elements from specific XML schema

#16 Post by Aacini » 08 Nov 2022 05:33

Alanick wrote:
07 Nov 2022 18:59

Hm, for some odd reason, on some of the <float_array> elements have the following result:
error.png
A big chunk from the end of the float_array, gets copied after </float_array> while adding once again the </float_array> closing element, the next element called <technique_common> is copied right after it including its indentation, thus corrupting the XMLs correct syntax.

Try to identify the TAG where such a float_array appears (I think it is a <library_geometries> one) and the input FILE where such a TAG appears for the first time. Then, do a test with such a file and one file before and one file file after, and confirm that the error appears in the generated output.txt file.

After that, post here the 3 input files so I have data to perform some tests and try to erradicate this problem.

I have an idea of the cause of this problem, but I need example data in order to confirm it.

Antonio

Alanick
Posts: 12
Joined: 29 Oct 2022 14:06

Re: Copy tags and its child elements from specific XML schema

#17 Post by Alanick » 08 Nov 2022 17:58

Aacini wrote:
08 Nov 2022 05:33
(I think it is a <library_geometries> one)
That is correct.
Aacini wrote:
08 Nov 2022 05:33
the input FILE where such a TAG appears for the first time.
The first culprit where it seems to all start is file 0104.xml, (oddly enough the file is of course correct, during merging it gets corrupt).
Aacini wrote:
08 Nov 2022 05:33
Then, do a test with such a file and one file before and one file file after, and confirm that the error appears in the generated output.txt file.
Files 0103.xml, 0104.xml, 0105.xml have been tested as follows:
All three where merged together as first test, second 0103 + 0104, third 0104 + 0105.
On all three tests, the corrupt output.txt occurred as shown in screenshot from previous post.
Aacini wrote:
08 Nov 2022 05:33
After that, post here the 3 input files so I have data to perform some tests and try to eradicate this problem.
samples_03.zip
Last edited by Alanick on 10 Nov 2022 14:08, edited 2 times in total.

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Copy tags and its child elements from specific XML schema

#18 Post by Aacini » 10 Nov 2022 11:40

I think I identified and solved the special cases that caused the long-line problems. This is the last version:

Code: Select all

@echo off
setlocal EnableDelayedExpansion

REM https://www.dostips.com/forum/viewtopic.php?f=3&t=10579
REM Antonio Perez Ayala
REM Version 2: Manage long lines
REM Version 3: Modified method to process whole files one-by-one
REM Version 4: Long lines special cases fixed

if "%1" neq "" goto ProcessFile

rem In this version 3 each file is processed completely
rem so each tag of every file is stored in its own file
rem At end, all tag files are combined in output.txt result file

rem Create a file with a space and no CR-LF at end
for %%X in (^"^
% Do NOT remove this line %
^") do set /P "=X%%~X " < NUL > space.tmp
findstr /V "X" space.tmp > space.txt
del *.tmp output.txt tags.txt

ECHO %time:~0,-3% Start Job
for /F %%a in ('echo prompt $H ^| cmd') do set "BS=%%a"
set "spin=v<^>"
set i=0
set "firstFile=true"
for %%f in (*.xml) do (
   set /A i+=1
   cmd /C "%~F0" !i! %%f
   set "firstFile="
)

ECHO %time:~0,-3% - All input files processed, creating output.txt file
(
   for /F "delims=" %%a in (tags.txt) do (
      for /F "tokens=2 delims=</>" %%f in ("%%a") do (
         type "tagData-%%f.tmp"
         echo %%a
      )
   )
   echo ^</COLLADA^>
) >> output.txt

ECHO %time:~0,-3% End Job
del *.tmp tags.txt space.txt
goto :EOF


=================================================


:ProcessFile i file		Process all tags of the file given as parameter

for %%f in (%2) do set /A "size=%%~Zf/1024"
ECHO %time:~0,-3% - Process file #%1: %2 (%size% KB)

set "inTag="
rem Assemble a While-loop to read all file lines
< "%2" ( for /L %%? in () do (

   rem Read next line; if EOF: exit
   set "line="
   set /P "line="
   if "!line!" equ "" exit

   if not defined inTag (
      rem First part: Copy/Ignore up to "</asset>" input line
      if defined firstFile >> output.txt echo !line!
      if "!line!" equ "  </asset>" (
         set "inTag=1"
         set "tagName="
      )
   ) else for /F "tokens=2 delims=<>" %%b in ("!line!") do (
      rem Second part: Copy each tag and its children to it's own file

      if not defined tagName (
         rem Start of tagNameN

         set "tagName=%%b"
         set "childName="
         set /A "add=0, omit=0"
         SET /P "=|        - - TAG !tagName!: " < NUL

         if defined firstFile (
            rem Initialize files for tagData and childIds of this tagName
            > "tagData-!tagName!.tmp" echo !line!
            del "childIds-!tagName!.tmp" 2> NUL
         ) else (
            rem Load current childIds of this tagName
            setlocal EnableDelayedExpansion
            for /F "usebackq" %%i in ("childIds-!tagName!.tmp") do set "child[%%i]=1"
         )

      ) else if "%%b" equ "/!tagName!" (
         rem End of tagNameN

         ECHO !add! items added, !omit! omitted

         if defined firstFile (
            rem Store the closing line for this tagData file
            >> tags.txt echo !line!
         ) else (
            rem Release childIds of this tagName
            endlocal
         )

         set "tagName="

      ) else if not defined childName (
         rem Start of new child of tagNameN

         set /P "=!spin:~0,1!!BS!" < NUL
         set "spin=!spin:~1!!spin:~0,1!"

         for /F "tokens=1,3 delims=<= " %%c in ("%%b") do set "childName=%%c" & set "childId=%%~d"
         if not defined child[!childId!] (
            >> "tagData-!tagName!.tmp" echo !line!
            >> "childIds-!tagName!.tmp" echo !childId!
            set /A "add+=1, inChild=1"
         ) else (
            set /A "omit+=1"
            set "inChild="
         )

      ) else if "%%b" equ "/!childName!" (
         rem End of this child

         set "childName="
         if defined inChild >> "tagData-!tagName!.tmp" echo !line!
         set "inChild="

      ) else (
         rem Any other line
         (
         if "!line:~1022!" neq "" call :longLine
         if defined inChild echo !line!
         ) >> "tagData-!tagName!.tmp" 
      )

   )

) )

rem Previous ") )" close a While-loop: ( for /L %%? in () do (
rem so execution never reach this point

=======================================

:longLine
if not defined inChild set "line=" & goto readLine

if "%line:~0,1%" equ " " (
   type space.txt
   set "line=%line:~1%"
   goto longLine
)
set /P "=%line%" < NUL

set "line="
:readLine
set /P "line="
if "!line!" equ "" goto readLine
if "!line:~0,6!" neq "      " goto longLine
if defined inChild echo/
exit /B
Test it and report the result...

Antonio

miskox
Posts: 553
Joined: 28 Jun 2010 03:46

Re: Copy tags and its child elements from specific XML schema

#19 Post by miskox » 10 Nov 2022 12:16

I like the spinning, Antonio! Great!

You never stop to amaze me with your methods! Very clever methods.

Thanks.
Saso

Alanick
Posts: 12
Joined: 29 Oct 2022 14:06

Re: Copy tags and its child elements from specific XML schema

#20 Post by Alanick » 10 Nov 2022 20:28

Aacini wrote:
10 Nov 2022 11:40
Test it and report the result...
I am lost for words, i am beginning to believe now all the things i have read up until I've reached this forum, it seems it will be impossible to achieve this via dos batch, now the entire library_geometries tag is corrupt, the opening/closing tags of its child elements are all messed up, this time around i have no clue how to even describe what exactly is wrong, i am baffled :(

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Copy tags and its child elements from specific XML schema

#21 Post by Aacini » 11 Nov 2022 19:40

Alanick wrote:
10 Nov 2022 20:28
I am lost for words, now the entire library_geometries tag is corrupt, the opening/closing tags of its child elements are all messed up, this time around i have no clue how to even describe what exactly is wrong, i am baffled :(
Mmmm... You don't need to search for superlative adjetives to describe the problem; just post a segment of the output file that present the problem... Why you didn't do that?


I completed several tests with the provided data files and compared the output of my previous code version vs. the last one. I first completed a test with files 001.xml, 002.xml and 003.xml. The output of both code versions is exactly the same...


Then I did a test with files 0813.xml, 0819.xml and 0911.xml. With these files the old code fail when processing the <library_geometries> tag of files #2 and #3, so the trace not reports how many child items were processed from these files. The new code correctly process all child items of all files and the trace reports 20 items added from file #2 and 32 from file #3, so the generated output.txt file is significantly larger than the old version's one.

I taken the generated 7,570 KB output.txt file and removed all excepting the first and the two last items of library_geometries tag, and shortened all float_array and p long fields. This is the result:

Code: Select all

  <library_geometries>
    <geometry id="0x2BE72C7D" name="XT_BUSH_FOREST_SMACK1A_JG_00">
      <mesh>
        <source id="0x2BE72C7D_positions" name="position">
          <float_array id="0x2BE72C7D_positions_array" count="132">0.035645 -1.103516 ... -0.389191 0.442637</float_array>
          <technique_common>
            <accessor count="44" source="#0x2BE72C7D_positions_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x2BE72C7D_texcoords" name="texcoords">
          <float_array id="0x2BE72C7D_texcoords_array" count="88">0.589844 -0.000000 ... -1.000000 0.589844 -1.000000</float_array>
          <technique_common>
            <accessor count="44" source="#0x2BE72C7D_texcoords_array" stride="2">
              <param name="S" type="float" />
              <param name="T" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x2BE72C7D_mat0_normals" name="normal">
          <float_array id="0x2BE72C7D_mat0_normals_array" count="132">-0.579751 -0.710834 ... -0.405257 0.527302</float_array>
          <technique_common>
            <accessor count="44" source="#0x2BE72C7D_mat0_normals_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x2BE72C7D_mat0_colors" name="color">
          <float_array id="0x2BE72C7D_mat0_colors_array" count="132">0.325490 0.325490 ... 0.325490 0.325490 0.325490</float_array>
          <technique_common>
            <accessor count="44" source="#0x2BE72C7D_mat0_colors_array" stride="3">
              <param name="R" type="float" />
              <param name="G" type="float" />
              <param name="B" type="float" />
            </accessor>
          </technique_common>
        </source>
        <vertices id="0x2BE72C7D_vertices">
          <input semantic="POSITION" source="#0x2BE72C7D_positions" />
        </vertices>
        <triangles count="22" material="material0">
          <input offset="0" semantic="VERTEX" source="#0x2BE72C7D_vertices" />
          <input offset="1" semantic="TEXCOORD" source="#0x2BE72C7D_texcoords" />
          <input offset="2" semantic="NORMAL" source="#0x2BE72C7D_mat0_normals" />
          <input offset="3" semantic="COLOR" source="#0x2BE72C7D_mat0_colors" />
          <p>0 0 0 0 1 1 1 1 2 2 2 2 2 2 2 2 ... 40 40 40 40</p>
        </triangles>
      </mesh>
    </geometry>

    . . . . .

    <geometry id="0xD46A6A25" name="XO_BOLLARDA_1B_CK_00_DEINST1_I11">
      <mesh>
        <source id="0xD46A6A25_positions" name="position">
          <float_array id="0xD46A6A25_positions_array" count="2202">932.502808 3513.485840 ... 3514.437744 200.145569</float_array>
          <technique_common>
            <accessor count="734" source="#0xD46A6A25_positions_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0xD46A6A25_texcoords" name="texcoords">
          <float_array id="0xD46A6A25_texcoords_array" count="1468">0.291016 ... 0.431641 -0.720703</float_array>
          <technique_common>
            <accessor count="734" source="#0xD46A6A25_texcoords_array" stride="2">
              <param name="S" type="float" />
              <param name="T" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0xD46A6A25_mat0_normals" name="normal">
          <float_array id="0xD46A6A25_mat0_normals_array" count="2202">0.000000 -1.000000 ... 0.000000 1.000000</float_array>
          <technique_common>
            <accessor count="734" source="#0xD46A6A25_mat0_normals_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0xD46A6A25_mat0_colors" name="color">
          <float_array id="0xD46A6A25_mat0_colors_array" count="2202">0.329412 ... 0.223529 0.223529</float_array>
          <technique_common>
            <accessor count="734" source="#0xD46A6A25_mat0_colors_array" stride="3">
              <param name="R" type="float" />
              <param name="G" type="float" />
              <param name="B" type="float" />
            </accessor>
          </technique_common>
        </source>
        <vertices id="0xD46A6A25_vertices">
          <input semantic="POSITION" source="#0xD46A6A25_positions" />
        </vertices>
        <triangles count="272" material="material0">
          <input offset="0" semantic="VERTEX" source="#0xD46A6A25_vertices" />
          <input offset="1" semantic="TEXCOORD" source="#0xD46A6A25_texcoords" />
          <input offset="2" semantic="NORMAL" source="#0xD46A6A25_mat0_normals" />
          <input offset="3" semantic="COLOR" source="#0xD46A6A25_mat0_colors" />
          <p>0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 ... 730 730 730 730</p>
        </triangles>
      </mesh>
    </geometry>
    <geometry id="0x55CA48D7" name="XT_GC_BUSH_1B_00_DEINST1_I11">
      <mesh>
        <source id="0x55CA48D7_positions" name="position">
          <float_array id="0x55CA48D7_positions_array" count="186">937.784851 ... 3588.885498 212.205322</float_array>
          <technique_common>
            <accessor count="62" source="#0x55CA48D7_positions_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x55CA48D7_texcoords" name="texcoords">
          <float_array id="0x55CA48D7_texcoords_array" count="124">0.505859 ... 1.000000 -1.000000</float_array>
          <technique_common>
            <accessor count="62" source="#0x55CA48D7_texcoords_array" stride="2">
              <param name="S" type="float" />
              <param name="T" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x55CA48D7_mat0_normals" name="normal">
          <float_array id="0x55CA48D7_mat0_normals_array" count="186">0.250123 ... -0.653945 0.004347</float_array>
          <technique_common>
            <accessor count="62" source="#0x55CA48D7_mat0_normals_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x55CA48D7_mat0_colors" name="color">
          <float_array id="0x55CA48D7_mat0_colors_array" count="186">0.121569 ... 0.105882 0.105882</float_array>
          <technique_common>
            <accessor count="62" source="#0x55CA48D7_mat0_colors_array" stride="3">
              <param name="R" type="float" />
              <param name="G" type="float" />
              <param name="B" type="float" />
            </accessor>
          </technique_common>
        </source>
        <vertices id="0x55CA48D7_vertices">
          <input semantic="POSITION" source="#0x55CA48D7_positions" />
        </vertices>
        <triangles count="28" material="material0">
          <input offset="0" semantic="VERTEX" source="#0x55CA48D7_vertices" />
          <input offset="1" semantic="TEXCOORD" source="#0x55CA48D7_texcoords" />
          <input offset="2" semantic="NORMAL" source="#0x55CA48D7_mat0_normals" />
          <input offset="3" semantic="COLOR" source="#0x55CA48D7_mat0_colors" />
          <p>0 0 0 0 1 1 1 1 ... 61 61 61 61</p>
        </triangles>
      </mesh>
    </geometry>
  </library_geometries>
Finally I did a similar test with 0103.xml, 0104.xml and 0105.xml files. In this case the generated output.txt files from the two code versions are also different. This is a FC comparison of both output.txt files:

Code: Select all

Comparando archivos output-OLD.txt y OUTPUT-NEW.TXT
***** output-OLD.txt
9766 -0.000000 0.666016 -1.000000 3.109375 -0.142578 3.109375 -0.000000 -1.10937
5 -0.000000 -1.109375 -0.142578 3.109375 -1.000
000 3.109375 -0.000000 -1.109375 -0.000000 -1.109375 -1.000000</float_array>578
3.109375 -1.000000 3.109375 -0.000000 -1.109375
 -0.000000 -1.109375 -1.000000 0.000000 -1.000000 0.000000 -0.000000 0.509766 -0
.000000 0.666016 -1.000000 3.109375 -0.142578 3
.109375 -0.000000 -1.109375 -0.000000 -1.109375 -0.142578 3.109375 -1.000000 3.1
09375 -0.000000 -1.109375 -0.000000 -1.109375 -
1.000000 0.000000 -1.000000 0.000000 -0.000000 0.509766 -0.000000 0.666016 -1.00
0000 3.109375 -0.142578 3.109375 -0.000000 -1.1
09375 -0.000000 -1.109375 -0.142578 3.109375 -1.000000 3.109375 -0.000000 -1.109
375 -0.000000 -1.109375 -1.000000 0.000000 -1.0
00000 0.000000 -0.000000 0.509766 -0.000000 0.666016 -1.000000 3.109375 -0.14257
8 3.109375 -0.000000 -1.109375 -0.000000 -1.109
375 -0.142578 3.109375 -1.000000 3.109375 -0.000000 -1.109375 -0.000000 -1.10937
5 -1.000000 0.000000 -1.000000 0.000000 -0.0000
00 0.509766 -0.000000 0.666016 -1.000000 3.109375 -0.142578 3.109375 -0.000000 -
1.109375 -0.000000 -1.109375 -0.142578 3.109375
 -1.000000 3.109375 -0.000000 -1.109375 -0.000000 -1.109375 -1.000000</float_arr
ay>          <technique_common>
            <accessor count="1554" source="#0xCDB9D0DA_texcoords_array" stride="
2">
***** OUTPUT-NEW.TXT
9766 -0.000000 0.666016 -1.000000 3.109375 -0.142578 3.109375 -0.000000 -1.10937
5 -0.000000 -1.109375 -0.142578 3.109375 -1.000
000 3.109375 -0.000000 -1.109375 -0.000000 -1.109375 -1.000000</float_array>
          <technique_common>
            <accessor count="1554" source="#0xCDB9D0DA_texcoords_array" stride="
2">
*****
The old version file have the error you reported: after the </float_array> closing tag a part of the same child field is repeated and the separation of the next <technique_common> tag is omitted. The new version output file have this error fixed. This is the only difference in these two files.

I taken this last output.txt file and deleted almost all of it excepting a couple items from <library_geometries> tag, and shortened its very long fields. This is the result:

Code: Select all

  <library_geometries>
    <geometry id="0x6A76F2DC" name="XO_HYDRANTA_1A_BK_00">
      <mesh>
        <source id="0x6A76F2DC_positions" name="position">
          <float_array id="0x6A76F2DC_positions_array" count="984">0.213135 0.000000 ... 0.202759 0.000000</float_array>
          <technique_common>
            <accessor count="328" source="#0x6A76F2DC_positions_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x6A76F2DC_texcoords" name="texcoords">
          <float_array id="0x6A76F2DC_texcoords_array" count="656">0.001953 -0.283203 ... 0.818359 -0.994141</float_array>
          <technique_common>
            <accessor count="328" source="#0x6A76F2DC_texcoords_array" stride="2">
              <param name="S" type="float" />
              <param name="T" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x6A76F2DC_mat0_normals" name="normal">
          <float_array id="0x6A76F2DC_mat0_normals_array" count="984">0.994190 0.107642 ... 0.000000 -1.000000</float_array>
          <technique_common>
            <accessor count="328" source="#0x6A76F2DC_mat0_normals_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x6A76F2DC_mat0_colors" name="color">
          <float_array id="0x6A76F2DC_mat0_colors_array" count="984">0.309804 0.309804 ... 0.184314 0.184314</float_array>
          <technique_common>
            <accessor count="328" source="#0x6A76F2DC_mat0_colors_array" stride="3">
              <param name="R" type="float" />
              <param name="G" type="float" />
              <param name="B" type="float" />
            </accessor>
          </technique_common>
        </source>
        <vertices id="0x6A76F2DC_vertices">
          <input semantic="POSITION" source="#0x6A76F2DC_positions" />
        </vertices>
        <triangles count="305" material="material0">
          <input offset="0" semantic="VERTEX" source="#0x6A76F2DC_vertices" />
          <input offset="1" semantic="TEXCOORD" source="#0x6A76F2DC_texcoords" />
          <input offset="2" semantic="NORMAL" source="#0x6A76F2DC_mat0_normals" />
          <input offset="3" semantic="COLOR" source="#0x6A76F2DC_mat0_colors" />
          <p>0 0 0 0 1 1 1 1 2 2 2 2 2 2 2 2 ... 326 326 326 326 313 313 313 313 324 324 324 324 327 327 327 327</p>
        </triangles>
      </mesh>
    </geometry>
    <geometry id="0x8327AAA3" name="XT_CT_FALLTREES_1B_JG_00">
      <mesh>
        <source id="0x8327AAA3_positions" name="position">
          <float_array id="0x8327AAA3_positions_array" count="1137">0.320007 0.413834 ... 0.007645 7.958358</float_array>
          <technique_common>
            <accessor count="379" source="#0x8327AAA3_positions_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x8327AAA3_texcoords" name="texcoords">
          <float_array id="0x8327AAA3_texcoords_array" count="758">2.000000 -0.695313 ... 1.000000 -1.000000</float_array>
          <technique_common>
            <accessor count="379" source="#0x8327AAA3_texcoords_array" stride="2">
              <param name="S" type="float" />
              <param name="T" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x8327AAA3_mat0_normals" name="normal">
          <float_array id="0x8327AAA3_mat0_normals_array" count="945">0.594168 0.798541 ... 0.954073 -0.030828</float_array>
          <technique_common>
            <accessor count="315" source="#0x8327AAA3_mat0_normals_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x8327AAA3_mat0_colors" name="color">
          <float_array id="0x8327AAA3_mat0_colors_array" count="945">0.227451 0.227451 ... 0.184314 0.184314</float_array>
          <technique_common>
            <accessor count="315" source="#0x8327AAA3_mat0_colors_array" stride="3">
              <param name="R" type="float" />
              <param name="G" type="float" />
              <param name="B" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x8327AAA3_mat1_normals" name="normal">
          <float_array id="0x8327AAA3_mat1_normals_array" count="192">-0.219406 -0.113456 ... -0.704975 0.053980 -0.707175</float_array>
          <technique_common>
            <accessor count="64" source="#0x8327AAA3_mat1_normals_array" stride="3">
              <param name="X" type="float" />
              <param name="Y" type="float" />
              <param name="Z" type="float" />
            </accessor>
          </technique_common>
        </source>
        <source id="0x8327AAA3_mat1_colors" name="color">
          <float_array id="0x8327AAA3_mat1_colors_array" count="192">0.270588 0.270588 ... 0.184314 0.184314</float_array>
          <technique_common>
            <accessor count="64" source="#0x8327AAA3_mat1_colors_array" stride="3">
              <param name="R" type="float" />
              <param name="G" type="float" />
              <param name="B" type="float" />
            </accessor>
          </technique_common>
        </source>
        <vertices id="0x8327AAA3_vertices">
          <input semantic="POSITION" source="#0x8327AAA3_positions" />
        </vertices>
        <triangles count="110" material="material0">
          <input offset="0" semantic="VERTEX" source="#0x8327AAA3_vertices" />
          <input offset="1" semantic="TEXCOORD" source="#0x8327AAA3_texcoords" />
          <input offset="2" semantic="NORMAL" source="#0x8327AAA3_mat0_normals" />
          <input offset="3" semantic="COLOR" source="#0x8327AAA3_mat0_colors" />
          <p>0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 ... 312 313 313 313 313 314 314 314 314</p>
        </triangles>
        <triangles count="32" material="material1">
          <input offset="0" semantic="VERTEX" source="#0x8327AAA3_vertices" />
          <input offset="1" semantic="TEXCOORD" source="#0x8327AAA3_texcoords" />
          <input offset="2" semantic="NORMAL" source="#0x8327AAA3_mat1_normals" />
          <input offset="3" semantic="COLOR" source="#0x8327AAA3_mat1_colors" />
          <p>315 315 0 0 316 316 1 1 317 317 ... 63 63 375 375 60 60</p>
        </triangles>
      </mesh>
    </geometry>
Sorry, but I can't find anyone of the problems you reported in the <library_geometries> tag. Of course, I just used the input files I have. If you found these errors when processing input files that I don't have, then it is obvious that I can't be aware of such problems...

Alanick wrote:
10 Nov 2022 20:28
i am beginning to believe now all the things i have read up until I've reached this forum, it seems it will be impossible to achieve this via dos batch
This type of comment is not good for casual users because they could think: "Yes, I heard several times that Batch files can't process xml files...", but they don't know the whole story! As I said before, although a Batch file is not the best way to process .xml files in general, it is possible to develop a Batch file that can solve your particular problem:
Aacini wrote:
02 Nov 2022 12:14
I suggest you to run my program with the same 3 data files you posted here and review the output.txt generated file. If you could identify the problems in the output result, perhaps I could write a patch in the program to fix just those points. This way I would not write a general method to solve these complex type of problems with a Batch file, but just a specific Batch file that solve your problem...

Please, be as clear as possible when you describe the problems with the actual program. You may post the specific line or section of the input data that cause problems, the output that is created now from such a data and the correct output you want. If the same type of problem appear several times, just describe it once. However, if a different problem also appear in another part of the data, describe it in the same way.

...

Antonio
The problem with this approach is that it takes some time. I write a new version, you test it and find some errors. I write a new version that fix those errors, you test it and find new errors... Perhaps this cycle needs to be repeated several times more in order to finally solve your problem. This is not uncommon at all, given the complexity of the task to solve. What I tried to say is that even if someone use a programming language that "correctly" manage .xml files, don't expect to get a final solution in the first or second version of the code...

I'm sorry you gave up on solving this task...

Antonio

Alanick
Posts: 12
Joined: 29 Oct 2022 14:06

Re: Copy tags and its child elements from specific XML schema

#22 Post by Alanick » 11 Nov 2022 22:50

Aacini wrote:
11 Nov 2022 19:40
I'm sorry you gave up on solving this task...
My apologies, for not getting back online quicker with a better replay, i surely did not give up on this project, nope, hehe.
Forgive my inexperienced nature in dealing with these kind of matters, i never thought it can become so twisted and tangled i might add.
I was just distracted by some more tests to at least have some sort of more in depth way of explaining what went wrong, being so many XMLs, there's lots to go through.

After several more tests it seems i was missing some obvious errors, the following is shown starting with the 0134 file, which i attached for further testing, if still possible.
There are quite a few with this error, again, i must add that neither of the XMLs that throw this error are corrupt, they are perfectly fine on their own, no clue whats happening during merging process, or maybe there might be something else i am missing.

Code: Select all

 6:11:57 - Process file #34: 0134.xml (6163 KB)
|        - - TAG library_images: 28 items added, 59 omitted
|        - - TAG library_materials: 28 items added, 59 omitted
|        - - TAG library_effects: 28 items added, 59 omitted
|        - - TAG library_geometries: The syntax of the command is incorrect.
If i remove the XMLs before this one, and start the batch the process with it, the process ends with the error, and and that's it, comes to a halt again.
sample_04.zip
Last edited by Alanick on 14 Nov 2022 17:19, edited 1 time in total.

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Copy tags and its child elements from specific XML schema

#23 Post by Aacini » 14 Nov 2022 08:40

Alanick wrote:
10 Nov 2022 20:28
I am lost for words, i am beginning to believe now all the things i have read up until I've reached this forum, it seems it will be impossible to achieve this via dos batch, now the entire library_geometries tag is corrupt, the opening/closing tags of its child elements are all messed up, this time around i have no clue how to even describe what exactly is wrong, i am baffled :(
When you posted this, you said: "now the entire library_geometries tag is corrupt". Because you said now, I assumed that it is a new error that havn't happened before... You didn't specified in which data file the error happened, nor described the error...

I was worried because I am not used to making mistakes of this magnitude, so I performed two tests, with previous and new code, over all groups of files I have, comparing the output files of both versions (looking for the opening/closing tags of its child elements messed up) and even I carefully edited the large output.txt files in order to keep a few elements from library_geometries tag so I can post such segments in this forum just to demonstrate that the entire library_geometries is NOT corrupt...

I spent a lot of time completing this test. IMHO I should use my time fixing errors instead of doing non-sense tests.

Anyway, this problem already took too much of my time...

Antonio

Alanick
Posts: 12
Joined: 29 Oct 2022 14:06

Re: Copy tags and its child elements from specific XML schema

#24 Post by Alanick » 14 Nov 2022 17:18

Aacini wrote:
14 Nov 2022 08:40
When you posted this, you said: "now the entire library_geometries tag is corrupt". Because you said now, I assumed that it is a new error that havn't happened before... You didn't specified in which data file the error happened, nor described the error...
At the time of writing that specific post, i did NOT seen that error that i specified already in the post above yours, WITH the sample that is causing the halt again, and the process does NOT progress forward, trying to process the ENTIRE project, with your last batch script it DOES INDEED corrupt the entire library_geometries, i was NOT expecting that, the error indeed happens on your very last updated batch script, even if i where to use the 0134 file as first file, which is posted above your post as well, the process will not continue, if there are files in front of it, the process continues with the specified error in the post above yours, BUT the tags and its child elements get corrupt in the final output.
Aacini wrote:
14 Nov 2022 08:40
I spent a lot of time completing this test. IMHO I should use my time fixing errors instead of doing non-sense tests.
As i mentioned, once again, in the post above yours, it took me a while to perform other tests to figure out what was going on, so it took me a while to get back to you to give a better response.
Aacini wrote:
14 Nov 2022 08:40
Anyway, this problem already took too much of my time...
Understood, thank you.

Post Reply