-
Notifications
You must be signed in to change notification settings - Fork 1
/
Clear xml Structure.jsx
85 lines (64 loc) · 1.92 KB
/
Clear xml Structure.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// a quick script for removing everything in the structure the safe way
// written by fabian theblind
// needs glue code for softies
// SOME TEXT
// Copyright (C) 2011 Fabian "fabiantheblind" Morón Zirfas
// http://www.the-moron.net
// info [at] the - moron . net
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/.
#include "./meta/glue code.jsx";
main();
function main(){
try {
var myDoc = app.activeDocument;
} catch(e){
alert("No no no, you have no document.\nMaybe you should drink some coffee");
return;
}
// var dlg = app.dialogs.add({name:"the Link Button", canCancel:true});
// with(dlg){
// with(dialogColumns.add()){
// staticTexts.add({staticLabel:"Are You shure you want to clear the whole structure?"});
//
// }
// }
// if(dlg.show==true){
// dlg.destroy();
// }else{
// dlg.destroy();
// return;
// }
// // the soft way?
// try{
// untagAllxmlElements(myDoc);
// }catch(e){
//
//
// }
// the hard way?
myDoc.xmlElements.everyItem().remove();
}
function untagAllxmlElements(myDoc){
var myRuleSet = new Array(new allElements());
with(myDoc){
var elements = xmlElements;
__processRuleSet(elements.everyItem(), myRuleSet);
}
}
function allElements(){
this.name = "allElements";
this.xpath = "/Root/*";
this.apply = function(myElement, myRuleProcessor){
__skipChildren(myRuleProcessor);
myElement.untag();
};
}