2017-09-22 1 views
0

Was ich versuche zu erreichen ist: Ich möchte 10.000 Preise in meinem InDesign-Katalog automatisch aktualisieren. Der einzige Weg, dies zu tun, ist die Verwendung von XML. Wenn ich meine Tabellenzellen in indesign beschreibe, kann ich eine XML-Datei exportieren, die so aussieht.Suchen und ersetzen Inhalt zwischen XML-Tags aus einer anderen Datei

-<Root> 
-<Artikel> 
-<Tabel aid:tcols="5" aid:trows="6" aid:table="table" xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"> 
<Cel aid:table="cell" aid:ccols="5" aid:crows="1">.: Rollerflam </Cel> 
<Cel aid:table="cell" aid:ccols="5" aid:crows="1"/> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="79.29730708729332"/> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="65.97828346376967">Artikel code</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="144.56692913385828">Omschrijving</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="42.519685039370074">Prijs/st.</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="34.01574803149606">PG</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="3" aid:ccolwidth="79.29730708729332"/> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="65.97828346376967">AIRK7274</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="144.56692913385828">Rollerflampost </Cel> 
-<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="42.519685039370074"> 

<AIRK7274>717,00</AIRK7274> 

</Cel> 

<Cel aid:table="cell" aid:ccols="1" aid:crows="3" aid:ccolwidth="34.01574803149606">-</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="65.97828346376967">AIRK7275</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="144.56692913385828">Rollerflampost met lastoebehoren</Cel> 
+<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="42.519685039370074"> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="65.97828346376967">AIRK7277</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="144.56692913385828">Rollerflampost +las-en snijtoebehoren</Cel> 
-<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="42.519685039370074"> 

<AIRK7277>1055,00</AIRK7277> 

</Cel> 
</Tabel> 
</Artikel> 

-<Artikel> 
-<Tabel aid:tcols="5" aid:trows="7" aid:table="table" xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"> 
<Cel aid:table="cell" aid:ccols="5" aid:crows="1">.: Junior flessen </Cel> 
<Cel aid:table="cell" aid:ccols="5" aid:crows="1"/> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="79.29730708729332"/> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="65.97828346376964">Artikel code</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="144.56692913385828">Omschrijving</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="42.519685039370074">Prijs/st.</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="34.01574803149606">PG</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="79.29730708729332"/> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="65.97828346376964">AIRK7272</Cel> 
<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="144.56692913385828">Fles met vulling van 2.30m³ zuurstof</Cel> 
-<Cel aid:table="cell" aid:ccols="1" aid:crows="1" aid:ccolwidth="42.519685039370074"> 

<AIRK7272>345,00</AIRK7272> 

</Cel> 

Dies sind nur ein paar Artikel. Jetzt habe ich eine Liste aller diesen Artikel mit Tags, die wie diese

<AIRK7274>222</AIRK7274> 
<AIRK7275>222</AIRK7275> 
<AIRK7277>1055</AIRK7277> 
<AIRK7272>345</AIRK7272> 
<AIRK7271>309</AIRK7271> 
<AIRK7276>310</AIRK7276> 
<AIRK7270>310</AIRK7270> 
<AIR01150>42</AIR01150> 
<AIR02150>42</AIR02150> 
<AIR08193>42</AIR08193> 
<AIR08197>42</AIR08197> 
<AIR73142>39,5</AIR73142> 
<AIRK7250>291</AIRK7250> 
<AIRK7280>435</AIRK7280> 
<BI1410>15,746</BI1410> 

aussieht, ist es möglich, den Inhalt zwischen den XML-Tags der Indesign-Datei mit dem Inhalt meiner Datei zu ersetzen? Ich habe über XML-Parser und Regex gelesen, aber ich verstehe es noch nicht wirklich. Könnte jemand versuchen, mir eine gute Erklärung dafür zu geben und mir sagen, wenn es möglich ist, was ich versuche zu erreichen? Vielen Dank im Voraus!

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
+0

Ja, das ist im allgemeinen Fall möglich. Geben Sie jedoch an, welche Sprache Sie für die XML-Verarbeitung verwenden. –

+0

Ich denke du meinst diese Zeile Christophe

Antwort

0

@Loic

Ich glaube, ich die Antwort gefunden. I entfernt

xe.contents = String(Number (String(tag).replace (/,/g, "."))*2).replace (/\./g, ","); 

und ersetzte sie durch

xe.contents = String(tag).replace (/,/g, ".") .replace (/\./g, ","); 

Es scheint zu funktionieren und Problem gelöst danke Loic für Ihre Hilfe!

0

Hier ist ein möglicher Ansatz, indem der Zugang der InDesign Scripting DOM:

var main = function() { 
 
\t var doc = app.properties.activeDocument, 
 
\t root, xe, price, 
 
\t tags = <tags> 
 
<AIRK7274>222</AIRK7274> 
 
<AIRK7275>222</AIRK7275> 
 
<AIRK7277>1055</AIRK7277> 
 
<AIRK7272>345</AIRK7272> 
 
<AIRK7271>309</AIRK7271> 
 
<AIRK7276>310</AIRK7276> 
 
<AIRK7270>310</AIRK7270> 
 
<AIR01150>42</AIR01150> 
 
<AIR02150>42</AIR02150> 
 
<AIR08193>42</AIR08193> 
 
<AIR08197>42</AIR08197> 
 
<AIR73142>39,5</AIR73142> 
 
<AIRK7250>291</AIRK7250> 
 
<AIRK7280>435</AIRK7280> 
 
<BI1410>15,746</BI1410> 
 
</tags>, tag, xes; 
 
\t 
 
\t 
 
\t if (!doc) return; 
 
\t 
 
\t root = doc.xmlElements[0]; 
 
\t 
 
\t tags = tags.children(), n = tags.length(); 
 
\t 
 
\t while (n--) { 
 
\t \t tag = tags[n]; 
 
\t \t xes = root.evaluateXPathExpression (".//"+ String(tag.name())); 
 
\t \t if (xes.length) { 
 
\t \t \t xe = xes[0]; 
 
\t \t \t xe.contents = String(Number (String(tag).replace (/,/g, "."))*2).replace (/\./g, ","); 
 
\t \t } 
 
\t } 
 
} 
 

 

 
var u; 
 

 
app.doScript ("main()",u,u,UndoModes.ENTIRE_SCRIPT, "The Script");

Before script is run After Script is run. Prices get doubled…

+0

Vielen Dank Loic! Es gibt nur noch eine Sache, die ich erreichen möchte, und zwar jeden Preis mit 2 Dezimalstellen. Zum Beispiel: Wenn der Preis sagt „717,45“ den Preis in indesign als „717,45“ zurückgibt, wenn der Preis sagt „717,00“ den Preis in indesign kehrt als „717“ Hat jemand eine Lösung dafür? – Christophe

0

war in der Tat die "mal 2" ein Beispiel dafür, was du könntest es tun. Um "runde" Zahlen, wenn nötig, sie gibt viele Möglichkeiten, aber eine schnelle Lösung könnte darin bestehen, in:

xe.contents = String(Number (String(tag).replace (/,/g, "."))*2).replace (/\./g, ",").replace (',00', '');

+0

Danke Loic für deine Antwort, aber ich denke, du hast die Frage falsch gelesen oder wahrscheinlich habe ich es nicht gut erklärt. Ich möchte nicht, dass es die Preise abrundet. Also, wenn ich "717,00" in das Skript einfüge, gibt indesign "717" zurück und nicht "717,00", wie ich es möchte. Gibt es eine Möglichkeit für InDesign, genau das zurückzugeben, was ich zwischen die Tags gesetzt habe? – Christophe

Verwandte Themen