🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
7 messages
7 total messages Started by Siegfried_Kauschat Thu, 05 Feb 2009 11:12
Access image placed by xml-rules
#1512
Author: Siegfried_Kauschat
Date: Thu, 05 Feb 2009 11:12
25 lines
1330 bytes
Hi, I have to modify an image (width/height) which is placed by xml-rules.

XML:
... 

      <sometag> <Symbol typ="new" href="myimage.tif"/> </sometag> ...





JavaScript:
... 

      function SymbolRule() { this.name = "Symbol"; this.xpath = "//sometag/Symbol[@typ='new']";
      this.apply = function (element, ruleProcessor) { with (element) { applyObjectStyle("somestyle");
      } }
      ...





How can I now access this image to modify its properties?
I've read <http://www.adobeforums.com/webx/.59b7295a/2> but I don't understand *where* to place the code to access the image. Is it possible to do it in my XML-Rule SymbolRule()? Or is it "to early" because the image is no yet placed in the document?
Re: Access image placed by xml-rules
#1530
Author: Bob Stucky
Date: Thu, 05 Feb 2009 16:57
22 lines
1292 bytes
Siegfried,

I'm not certain that I fully understand your question. But here's an answer to what I think you're asking.

Once you create a rule (or a bunch of rules), you invoke them using the rule processor's glue code.

(InDesign CS4/Scripts/XML Rules/glue code.jsx)

In that script you'll see:

function __processRuleSet (root, ruleSet, prefixMappingTable)

In your code, AFTER you have imported your xml, you'll need to call this function with the appropriate XML element and an array or rules to process.

var root = app.activeDocument.xmlElements[ 0 ];
var ruleSet = [ new SymbolRule() ];

__processRuleSet( root, ruleSet );

Does that answer the question?

Bob
Re: Access image placed by xml-rules
#1546
Author: Siegfried_Kauschat
Date: Thu, 05 Feb 2009 20:18
3 lines
1267 bytes
Bob, thank you for your answer. I already use the glue code, and processing the rules is working correctly. I see a populated document after running my script (also the image of the Symbol-Tag). My problem is that I have to modify this image (get smaller). And I like to do that as early/easily as possible. And I ask myself (and this group ;-) if it is already possible in the rule-function of this xml-element (how?) or if I have to process the rule, place the xml in document and after that navigate through the placed images to my desired one (is it possible by using the xml-id)?

Siegfried
Re: Access image placed by xml-rules
#1408
Author: Stefan_Rakete
Date: Fri, 06 Feb 2009 08:08
15 lines
880 bytes
Hi Siegfried,

in your Xml-Rule above add the line

var myRectangle = myElement.xmlContent.parent;

with (element) {
 applyObjectStyle("somestyle");
 var myRectangle = myElement.xmlContent.parent;
 ... do something with your rectangle here, e,g. scale it
}

Hope this helps.

Stefan
Re: Access image placed by xml-rules
#1418
Author: Siegfried_Kauschat
Date: Fri, 06 Feb 2009 16:01
13 lines
1297 bytes
Hi Stefan,

thank you for your answer. I've read your former posts to similar problems and always wondered about the data types of element and co.:

$.writeln(element) -> [object XMLElement]
$.writeln(element.parent) -> [object XMLElement]
$.writeln(element.xmlContent) -> [object Text]
$.writeln(element.xmlContent.parent) -> [object XmlStory]

Are that the expected data types?

I think XmlStory is not the expected type to look for my rectangle. And why is element.xmlContent a text object? Even Indesign shows this node with the icon for "graphic node" - an I see the image in the document after processing the rule-script.
What else than the href-attribute makes an xml-node a "graphic" one?
Re: Access image placed by xml-rules
#1423
Author: Olav_Kvern
Date: Fri, 06 Feb 2009 21:07
11 lines
1248 bytes
Hi Siegfried,

If the parent of the element is an XMLStory, that means that the Element is not placed anywhere in the layout. When a graphic is contained by an unplaced XML element, it is an inline/anchored object--i.e., it's contained by a text character. Is it possible that the element has not yet been placed in the layout at the point at which you're getting the types?

Whether or not that remains true depends on how you place the graphic in the layout--you can place it as either an inline graphic or an independent graphic.

Once you place the XML in a layout, the type of the parent element of the content will change.

Thanks,

Ole
Re: Access image placed by xml-rules
#1305
Author: Siegfried_Kauschat
Date: Mon, 09 Feb 2009 10:47
12 lines
1185 bytes
Hi Ole, that's it, thank you very much!

The following code works fine within the apply-function if you first do the placeXML and after that call __processRuleSet:

xmlContent.parent.verticalScale = 50;
xmlContent.parent.horizontalScale = 50;

So I think it's a good idea to call __processRuleSet (with different rule sets) more than one time:

1. process the first ruleSet to handle all the steps that do not need to refer to placed frames e.g. formatting steps
2. place xml in the page
3. do all layout related steps that need to access the text/img container frames
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads