Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Adobe Indesign with aid tags

Participant ,
Jul 28, 2023 Jul 28, 2023

I have to read an indesign.xmlelement.But in the input XML I am having aid:pstyle and aid:cstyle tags.When i am using EvaluateXPathExpression it does not return any value.

In the XML

<table-group></table-group> when i am using rootElement.EvaluateXPathExpression("//table-group") it gives the correct output.

But when I am using <p aid:pstyle="Tx1"></p> It does not return anything. Can you please kindly suggest me to handle aid: attributes containing tags?

 

TOPICS
EPUB
452
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Explorer , Jul 28, 2023 Jul 28, 2023

pstyle attribute is namespaced (aid), so you have to include that in your xpath.

A possible way is:

var doc = app.activeDocument;
var root = doc.xmlElements[0];
var elem = root.evaluateXPathExpression('//p[@*[local-name()="pstyle" and namespace-uri()="http://ns.adobe.com/AdobeInDesign/4.0/" and .="Tx1"]]');
if(elem.length==0){
    alert("No elements found");
 }
 else{
    elem = elem[0];
    var xc = elem.xmlContent;
    if(xc.constructor.name=="Text"){
        alert(elem.contents)
    }
    else{
...
Translate
People's Champ , Aug 01, 2023 Aug 01, 2023

Can you try with Javascript to see where the issue resides? If the javascript works fine, then it means the problem is using the XPath with VB.net. Maybe some xpath expressions are not usable in VB.net or you have to tweak something to make it VB.net compliant.

Also what you can try is start using simpler xpath and add complexity little by little. There you can see where expression interpretation fails.

Cannot help more.

Translate
Explorer ,
Jul 28, 2023 Jul 28, 2023

pstyle attribute is namespaced (aid), so you have to include that in your xpath.

A possible way is:

var doc = app.activeDocument;
var root = doc.xmlElements[0];
var elem = root.evaluateXPathExpression('//p[@*[local-name()="pstyle" and namespace-uri()="http://ns.adobe.com/AdobeInDesign/4.0/" and .="Tx1"]]');
if(elem.length==0){
    alert("No elements found");
 }
 else{
    elem = elem[0];
    var xc = elem.xmlContent;
    if(xc.constructor.name=="Text"){
        alert(elem.contents)
    }
    else{
        alert(elem);
    }
    
 } 

May be simpler approaches but that one seems to work.

Loic

PS: You did not mark your question as scripting related, you would have certainly got quicker feedback if you did.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 28, 2023 Jul 28, 2023

Hi thanks for ur reply. But when i am trying this i get Expression expected Error. I am using vb.net 2019 . Thanks once again

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Aug 01, 2023 Aug 01, 2023

Can you try with Javascript to see where the issue resides? If the javascript works fine, then it means the problem is using the XPath with VB.net. Maybe some xpath expressions are not usable in VB.net or you have to tweak something to make it VB.net compliant.

Also what you can try is start using simpler xpath and add complexity little by little. There you can see where expression interpretation fails.

Cannot help more.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 01, 2023 Aug 01, 2023
LATEST

I added xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" attributes in the P tags where the output not coming. Now the output comes as expected. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines