2017-09-22 8 views
0

私が達成しようとしているのは 私のindesignカタログの10.000の価格を自動的に更新したいと思います。 これを行う唯一の方法は、XMLを使用することです。 私のテーブルセルをindesignでラベル付けすると、このようなXMLファイルをエクスポートできます。他のファイルのXMLタグ間でコンテンツを検索して置き換えます

-<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> 

これはほんの一部の記事です。 今私はそれが私のファイルの内容とのInDesignファイルのXMLタグの間にコンテンツを交換することが可能である。この

<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> 

のように見えるタグを持つすべてのこれらの記事のリストを持っていますか? 私はXMLパーサーと正規表現について読んだことがありますが、私はまだそれを理解していません。 誰も私にこのことについての良い説明をして、達成しようとしていることが可能かどうか教えてもらえますか?ありがとうございます!ここで

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

はい、一般的に可能です。ただし、xml処理にはどのような言語を使用するかを指定します。 –

+0

あなたはこの行を意味すると思いますか?<?xml version = "1.0" encoding = "UTF-8" standalone = "yes"?> – Christophe

答えて

0

@Loic

。 は私が

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

を取り出して、あなたの助けにロイックに感謝動作すると問題が解決されると思われる

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

に置き換え!

0

は、アクセスすることによって可能なアプローチは、InDesignスクリプティング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

ありがとうLoic!達成したいと思うもう一つのことがあります。それは、すべての価格を2小数で表示することです。たとえば :価格は価格は「717,00」は、それが「717」 としてのInDesignで価格を返すと言うときに「717,45」は、それが「717,45」 としてのInDesignで価格を返すと言う 誰にもその修正がありますか? – Christophe

0

確かに "2倍" は何の例でしたあなたはすることができます。 「ラウンド」番号、必要なときに、彼らは多くの方法ですが、簡単な修正はして構成することができ:私は答えを見つけたと思う

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

+0

お返事ありがとうございましたが、質問を誤解したと思いますが、おそらく私はそれをうまく説明しませんでした。 私はそれが価格を丸めることを望んでいません。 それで、私が "717,00"をスクリプトの中に入れると、indesignは "717"を返し、 "717,00"を返しません。 indesignがタグの間に置いたものを正確に返す方法はありますか? – Christophe

関連する問題