Create text online the content of a xml tag frame?
Hello! I have a pretty big document created from an XML file, and I would like to convert a series of my XML tags to the anchor text blocks, so I can hang them on the left edge of the lines they appear in.
My XML file is converted into a
> root
> Chapter
> para
> id
1
> verse
text
> id
> verse
etc... See extract file here http://1drv.ms/1dX6lYO
So far, I have the following, which gets me an array containing all the elements ID.
var myDocument = app.activeDocument; var myXMLidElement = myDocument.xmlElements.itemByName("book").xmlElements.itemByName("c").xmlElements.itemByName("p").xmlElements.itemByName("id"); var myXMLidText= (myXMLidElement.contents); var myXMLidLength = myXMLidText.length; for (var i = 0; i < myXMLidLength; i++) { //loop to go through //alert (myXMLidText[i]); myDocument.select(myXMLidText[0]); //this gives me an error saying expected data type needs to be array. Can someone explain? Where do I find info on the select command? myDocument.selection[0].insertionPoints[0].textFrames.add(myXMLidText[0]); //haven't managed to get to this line yet, but I want it to create an inline text frame at the point of the selected text and set the frame's contents to be my XML Id Text
I guess I want and then delete all the text in my id too, but that's not important.
Some other random excerpts, I could use?
myInlineFrame.contents = "myXMLidText";
Guidance on the creation of the inline frames and the logic of loop? I'm an old hand with InDesign, but new to scripting, so be gentle.
Try this,
var myDocument = app.activeDocument; var root = myDocument.xmlElements[0]; var myXMLidElement = root.evaluateXPathExpression("//book/c/p/id"); for (var i = 0; i < myXMLidElement.length; i++) { myDocument.select(myXMLidElement[i]); var myTextframe = myXMLidElement[i].placeIntoInlineFrame(["1p","1p"]); }
Tags: InDesign
Similar Questions
-
How to pass the content of an xml element in the text frame in inDesign Script
var XMLFile = File.openDialog ("select XML Files... ») ;
var doc = app.activeDocument;
If (!) App.Documents.Length)
{alert ("ERROR: Document not opened");}
return;
}
doc.importXML (XMLFile);
var firstFigureNode = doc.xmlElements [0] .xmlElements [1] .xmlElements [0];
var lableNode = firstFigureNode.xmlElements [0];
var lableNodeText = lableNode.contents;
myFrame var = doc.textFrames.add ({geometricBounds: [-13, 13, 3, -3]});
lableNodeText.move (LocationOptions.AFTER, myFrame.texts [0]);
========================================================
My requirement is: == > > move the content of an xml element in the text by inDesign Script block, but XML InDesign file Structure should not be change & data in the XML Structure should remain as it was before...
I tried to code above, but it does not work...
Please can someone help me in solving this problem...
It does not work correctly...
It moves firstFigureNode in myFrame...
firstFigureNode.placeXML (myFrame);
===>> For Apple Script try below Code ===>>
myFrame markup using firstFigureNode
-
I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content
Hello
Can the code below is useful for you, but I do not know how to sort.
Change the tag based on your employment application.
-
Alteration of the content of an XML node in java
Hi all
I change the contents of an XML node using java, using the method of setTextContent() a node.
Sometimes I also add child nodes of a node. In this case, when I add the child nodes of a given node, when I print the xml data, I see the added nodes.
for example:
Initial XML:
< a > < / a >
< b > < / b >
< c > < / c >
For my project requirement, based on certain conditions, I do 'a' 'b', 'c' as children nodes nodes. I reached this output.
The problem is
FINAL XML:
< a > < b > < / b > < c > < / c > < / a >
I get the nodes children in the same line as above. But the power required should be as below.
REQUIRED XML
< a >
< b > < / b >
< c > < / c >
< /a >
I also used the Doc.normalize () function. But still, it helps strength.
Kindly help me in this regard.
Thank you
Sabarisri. NHello
You can try to transform the result as below:
Transformer transformer = TransformerFactory.newInstance () .newTransformer ();
transformer.setOutputProperty (OutputKeys.INDENT, 'yes');initialize the StreamResult with the object of the file to save to file
StreamResult result = new StreamResult (new StringWriter());DOMSource source = new DOMSource (doc); Here, the doc is you XML document.
transform. Transform (source, result);String xmlString = result.getWriter (m:System.NET.SocketAddress.ToString ());
System.out.println (xmlString);Thank you best regards &,.
Nilesh Sahni (www.infocepts.com)Published by: Nilesh on August 30, 2011 12:31
-
Hello
Is it possible in OSB, such that I can get the name of an XML tag for example if I want to assign the name of tag transactionType of the below mentioned XML to a variable, can I do it using an XQuery function?
<? XML version = "1.0" encoding = "UTF-8"? >
< tns:sandstonetns xmlns:tns = "http://sandstone.response.transactionHistory.app.nab.cz.fc.ofss.com" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://sandstone.response.transactionHistory.app.nab.cz.fc.ofss.com Sandstone_Data_Transaction_History_Response.xsd" > ""
< tns:listOfTransactions >
< tns:transactions >
< tns:clients >
< tns:clientID > tns:clientID < / tns:clientID >
< / tns:clients >
< tns:timestamp > 2001-12-31 T 12: 00:00 < / tns:timestamp >
< tns:sequenceNumber > tns:sequenceNumber < / tns:sequenceNumber >
< tns:description > tns:description < / tns:description >
< tns:amount > 0 < / tns:amount >
< tns:accountNumber > tns:accountNumber < / tns:accountNumber >
< tns:debitOrCreditFlag > tns:debitOrCreditFlag < / tns:debitOrCreditFlag >
* < tns:transactionType > all < / tns:transactionType > *.
< / tns:transactions >
< / tns:listOfTransactions >
< tns:returnResponse >
< tns:returnCode > 0 < / tns:returnCode >
< tns:returnDescription > tns:returnDescription < / tns:returnDescription >
< / tns:returnResponse >
< / tns:sandstonetns >
Published by: rahulc on January 19, 2011 04:43You can use fn:local - name ().
http://www.xqueryfunctions.com/XQ/fn_local-name.html
Kind regards
Anuj -
When the content in a text box is too big and must go beyond the next page, how can I do this? I can't so...
Click on the small red + sign below to the right. Then click on the next page.
If you hold the SHIFT key when you place the text it will sink to fill all the pages.
-
Creating text of the hyperlinks to different images in a movie!
Hello
I created a site in flash and have encountered a problem. I am using Flash CS3 and ActionScript 3.0.
I created a text box (for the moment it is dynamic, because I have it scrolling) with text entered in it. I want sections of text hyperlink to other images in the flash animation. The text box is on the 'new' framework - this is a page for archived news. I would like to highlight the pieces of text and create hyperlinks to each archived news stories (each of which is a different image).
I know how to create text buttons and link them at different times, but I don't want to do this because I want to keep the text box (with hyperlinks in the text) so that I can make this scrolling page.
I tried to highlight the text and hyperlinks to the frame number, the frame name, the anchor of the frame, CBS... but I can't get anything to work.
I hope this makes sense and I hope someone will have the time to help me! Thank you
The following would cause the first text to link to the 10 frame and the second at 20 frame...
aTextField.htmlText = "here is a link and here's another."
aTextField.addEventListener (TextEvent.LINK, linkEvent);function linkEvent(evt:TextEvent):void {}
gotoAndStop (Number (evt.text));
} -
Need help to retrieve the value of an xml tag.
Hi all
Hello all, I have problem to extract a value from an xml tag. I created an xml schema based on the schema, I created an xmltype table and inserted a value to the table. When I try to extract a value of a particular tag I can't do... Kindly help me to solve this problem. Here by I write all working, I did...
I use the following client:
-----------------------------------
SQL * more: Release 10.2.0.1.0 - Production on Mon 31 Jan 11:44: 59 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With partitioning, OLAP and Data Mining options
////////////////////////////////// XML Schema ///////////////////////
Start
() dbms_xmlschema.registerSchema
"http://www.oradev.com/chipsxml.xsd,"
' < scheme xmlns = "http://www.w3.org/2001/XMLSchema".
targetNamespace = "http://www.oradev.com/chipsxml.xsd."
xmlns:SAMP = "http://www.oradev.com/chipsxml.xsd".
version = "1.0" >
< feature name = 'Field1' >
< complexType >
<>sequence
< element name = "UTI" >
< complexType >
<>sequence
< element name = "U01" type = "string" / >
< element name = "U02" type = "string" / >
< element name = "U03" type = "string" / >
< element name = "U03a" type = "string" / >
< element name = "U03b" type = "string" / >
< element name = "U03c" type = "string" / >
< element name = "U04" type = "string" / >
< element name = "U05" type = "string" / >
< / sequence >
< / complexType >
< / item >
< / sequence >
< / complexType >
< / item >
< / schema > ',
(TRUE, TRUE, FALSE, FALSE);
end;
A table that has several column.
CREATE TABLE chipsxmltable1)
Identification number, XMLDATA XmlType)
XMLTYPE XMLDATA STORE AS OBJECT / RELATIONAL
XMLSCHEMA 'http://www.oradev.com/chipsxml.xsd '.
ELEMENT 'field1 ';
Insert the query in chipsxmltable.
INSERT INTO (VALUES) chipsxmltable
XmlType.CreateXml ("<?") XML version = "1.0"? >
< xmlns:samp samp: field1 = "http://www.oradev.com/chipsxml.xsd" >
< USE >
No. < U01 > < / U01 >
Y < U02 > < / U02 >
Y < U03 > < / U03 >
< U03a > Y < / U03a >
< U03b > Y < / U03b >
< U03c > Y < / U03c >
Y < U04 > < / U04 >
Y < U05 > < / U05 >
< / UTI >
((< / samp: field1 > '));
To display the data in a field with the structure:
--------------------------------------------
1. motion:
----------
Select * from chipsxmltable1;
Output:
-------
ID XMLDATA
---------- -----------------------------------------------------------------
1 <? XML version = "1.0"? >
< xmlns:samp samp: field1 = "http://www.oradev.com/chipsxml.xsd" >
< USE >
No. < U01 > < / U01 >
No. < U02 > < / U02 >
Y < U03 > < / U03 >
< U03a > Y < / U03a >
< U03b > Y < / U03b >
< U03c > Y < / U03c >
Y < U04 > < / U04 >
Y < U05 > < / U05 >
< / UTI >
< / samp: field1 >
2 query: (both the query shows the same result)
----------
SELECT X.xmldata.getClobVal ('XMLDATA' FROM chipsxmltable1 X);
Select extract (XMLDATA, "/ Field1'") .getstringval ("XMLDATA" chipsxmltable1 x);
Output:
--------
XMLDATA
-----------------------------------------------------------------
<? XML version = "1.0"? >
< xmlns:samp samp: field1 = "http://www.oradev.com/chipsxml.xsd" >
< USE >
No. < U01 > < / U01 >
No. < U02 > < / U02 >
Y < U03 > < / U03 >
< U03a > Y < / U03a >
< U03b > Y < / U03b >
< U03c > Y < / U03c >
Y < U04 > < / U04 >
Y < U05 > < / U05 >
< / UTI >
< / samp: field1 >
To display the data as a single string without structure using "getstringval()":
---------------------------------------------------------------------------------
3 query
---------
Select extract (XMLDATA, "//text()').getstringval()"CHIPS - XML"of chipsxmltable1 x;)
Output:
-------
CHIPS - XML
---------------------
NoNoYYYYYY
To display the data as a single string without structure using "getclobval()":
---------------------------------------------------------------------------------
4 query
-------
Select extract (XMLDATA, "//text()').getClobVal()"CHIPS - XML"of chipsxmltable1 x;)
Output:
--------
CHIPS - XML
-----------------
NoNoYYYYYY
To display the data in a tag with or without structure (which does work) using the function "EXTRACT":
-------------------------------------------------------------------------------------------------------------
6.query:
---------
Select extract (XMLDATA, "/Field1/text()').getstringval()"XMLDATA' chipsxmltable1 x;
Select extract (XMLDATA, "/Field1/UTI').getstringval()"XMLDATA' chipsxmltable1 x;
Select extract (XMLDATA, "/Field1/UTI/U01').getstringval()"XMLDATA' chipsxmltable1 x;
Select extract (XMLDATA, "/Field1/UTI/U01/text()').getstringval()"XMLDATA' chipsxmltable1 x;
Output:
--------
CHIPS - XML
---------------------------------------
The queries above are not fetch the value.
To display the data in a tag with or without structure (which does work) using the function "EXTRACTVALUE":
------------------------------------------------------------------------------------------------------------------
7 query:
----------
Select extractValue (XMLDATA, ' / Field1/UTI ') 'XMLDATA' of chipsxmltable1 x;
Select extractValue (XMLDATA, ' / U01/UTI/Field1 ') 'XMLDATA' of chipsxmltable1 x;
Output:
--------
X
-
The queries above are not fetch the value.
My question is:
--------------------
How to extract the values of xml tag when the value are inserted through xml schema?
My apologies if the description is not clear. Kindly let me know if further details are required. Thanks a lot for your help.
Very cordially,
Godwin Castro C.V.Hello
You must declare the namespace of each element used in the XPath expression, like this:
SQL> select extractvalue( XMLDATA 2 , '/samp:Field1/UTI/U01' 3 , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"' ) "XMLDATA" 4 from chipsxmltable1 x 5 ; XMLDATA -------------------------------------------------------------------------------- No
SQL> select extract( XMLDATA 2 , '/samp:Field1/UTI' 3 , 'xmlns:samp="http://www.oradev.com/chipsxml.xsd"' 4 ).getstringval() "XMLDATA" 5 from chipsxmltable1 x 6 ; XMLDATA --------------------------------------------------------------------------------
No Y Y Y Y Y Y Y Please see EXTRACT and EXTRACTVALUE documentation:
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions051.htm#i1006712
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions052.htm#SQLRF06173BTW, 'XMLDATA' is a pseudo-column used by Oracle. I don't know if it will never cause any conflict, but perhaps you need to rename your column.
http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/pseudocolumns010.htm#SQLRF00256Kind regards.
-
iOS: problem with loading the content of an xml file placed on a server
So, I have an app that loads a few small things (pictures and text) of a xml/php file on the server. Everything works fine on both android and in the flash debugger, but when I install the ipa file on my iPhone my IOErrorEvent displays an error message. When the xml file and example photos come with the app (they are not on the server, but in the ipa file) everything works perfectly. There is something about iOS that prevents me to load all the data from the server, it seems. There must be a way around it.
I would be grateful for advice.
Kind regards
Array must be table.
-
Creating instances of the class customized for XML nodes
Hi guys,.
I'm trying to load an external XML document in my application and create an instance of a custom class for each node in the XML file based on the value of some of their elements. Instances created later will end by in a DataGrid by the way. The problem I have is there seems to be several ways to make small parts of it and I have no idea how do them all gel. Initially, I use HTTPService to load the XML file, but I've seen people just use a XML object. Then, after that, I put the XML loaded to an ArrayCollection collection initially, but others used XMLList or XMLListCollection. I have no idea of what is the best way to do it.
Finally, when I created all of these instances by looping through XML and their creation how I'll make them bindable to the DataGrid? I guess I'll have to group together them somehow...
Any help would be greatly appreciated. Thank youCreate a class customized for your 'point' of dataGrid dataProvider objects
* Use HttpService to get the XML code.
* use an e4x expression for the child nodes of the xml in an XMLList: myXML.children () or myXML.myNodes;
* use a for loop on the XMLList
* inside of the loop, create a new instance of the custom class
* Of the [i] myXMLList, obtain all necessary attribute values and assign them to the appropriate properties in the instance of the custom class.
* always inside the loop, use myArrayCollection.addItem (mycustomClass) to add the element to the collection of the dataProvider ArrayCollection.Tracy
-
Extract the contents of an XML string in offline mode
HI gentlemen,
Could you help me solve this problem? I had a string of Java (see below) read in a smart German eHealth card. I have to extract the tag values and put them in local variables for further processing in my Java module. How to move forward without connecting to a database, it is enough to analyze the source - the string variable? Note that the lines are separated by only 0x0A.
Thank you very much for your help,<?xml version="1.0" encoding="ISO-8859-15" standalone="yes"?> <UC_PersoenlicheVersichertendatenXML CDM_VERSION="5.1.0" xmlns="http://ws.gematik.de/fa/vsds/UC_PersoenlicheVersichertendatenXML/v5.1"> <Versicherter> <Versicherten_ID>X110101627</Versicherten_ID> <Person> <Geburtsdatum>19840717</Geburtsdatum> <Vorname>Johanna</Vorname> <Nachname>Düsterbehn</Nachname> <Geschlecht>W</Geschlecht> <StrassenAdresse> <Postleitzahl>93055</Postleitzahl> <Ort>Regensburg</Ort> <Land> <Wohnsitzlaendercode>D</Wohnsitzlaendercode> </Land> <Strasse>Sulzfeldstraße</Strasse> <Hausnummer>7</Hausnummer> </StrassenAdresse> </Person> </Versicherter> </UC_PersoenlicheVersichertendatenXML>
sincere friendships of
Miklós HERBOLYjava.lang.NoClassDefFoundError: XpathSampleClass (wrong name: XPathSampleClass)
If you use my code sample in extenso, the class is named 'XPathSampleClass' (capital P), and of course the .class file must have the same name.
-
Replace the selected text with other content TextFrame
Hello
I am changing a text selected in something new, involving the movement of text and the paragraph style using a jsx script. At the present time, everything works beautifully:
- I entered the select text
- I have create a new temporary TextFrame
- I build my new paragraphs and apply styles to them in the new TextFrame
What I was not able to reach still is to replace the original selected text by temporary TextFrame content.
Any help would be more than welcome
A part of my script:
myText = app.selection[0].contents;
...
do some stuffvar myDocument = app.documents.item(0);
var myPage = myDocument.pages.item(0);
var myTextFrame = myPage.textFrames.add();
myTextFrame.geometricBounds = [0, -70, 150, 70];
myTextFrame.contents = "Paragraph1\rParagraph2...";
myTextFrame.paragraphs[0].appliedParagraphStyle = pStyleGroup.paragraphStyles.itemByName('Style1');
myTextFrame.paragraphs[1].appliedParagraphStyle = pStyleGroup.paragraphStyles.itemByName('Style2');
And now, in myTextFrame, I have my new paragraph formatted, and I would like to replace the original selected text with the contents of my TextFrame (keeping the paragraph styles).
Hello
Keep the logic of the code and edit utilities:
var mSourceIdx = app.selection[0].index, mStory = app.selection[0].parentStory, mReplaceStuff = { elements: [ ["Paragraph_1\r", "Style_1"], ["Paragraph_2\r", "Style_2"], ["Paragraph_X\r", "Style_X"] ]}, mTarget, cElement, cText, cParaStyle; while (cElement = mReplaceStuff.elements.pop()) { cText = cElement[0]; cParaStyle = app.activeDocument.paragraphStyles.item(cElement[1]); // modify if styleGroups present in a structure mTarget = mStory.insertionPoints.item(mSourceIdx); mTarget.contents = cText; mTarget.paragraphs[0].appliedParagraphStyle = cParaStyle; } app.selection[0].contents = "";
MReplaceStuff allows to prepare stuff to replace
Jarek
-
How to change content/type application/xml, text/xml?
Hi gurus B2B.
Now that I've worked on the transfer of files. Now, I tried to post the same document on an HTTP URL.
I see in the headers that the
Content-Type = application/XML
However, I need the Content-Type text/XML
Where can I get it changed?
Published by: user773213 on April 8, 2009 04:48If you use AQ together the content as part of QA header type (add below in the enqueue.properties).
actionName = CONTENTTYPE:text / xml;
concerning
Nebot -
Attachments such as Word or Excel files are shown only as attachments in a bar at the bottom of the message entering without rendering of such content. But Thunderbird always try to read the contents of an xml file in order to show ALL he's happy. If the file is large, it takes a lot of time, so the Thunderbirds crashes usually on, so I have to restart.
I would like to be able to make some adjustments to prevent display of the contents of the xml files attached in incoming messages. Thank you.
View (alt + V) menu > display the inline attachment
-
How creat text field on the time of execution
Hello.
How to creat text deposited the time of execution using the loop?
Can u please help me?
Thank you
Jaxna
Or make them more effective declare the TextFormat only once.
var aTexts:Array is ["hi1", "hi2", "hi3", 'hi4', 'hi5', "hi6", "hi7", "hi8", "hi9", 'hi10'];.
var myTextFormat:TextFormat = new TextFormat(); for the style of text
myTextFormat.size = 12;
myTextFormat.align = 'left '; left, right, Center
myTextFormat.color = 0xFF0000; Red
for (var i: Number = 0; i<10;>10;>
{
var nDepth:Number = this.getNextHighestDepth ();
var nX:Number = 10;
var nY:Number = 20 * i;
var nW:Number = 300;
var nH:Number = 30;
var myTextField:TextField = this.createTextField("hello_txt",0,10,10,100,20) ("txtField" + i, nDepth, nX, nY, nW, nH);
myTextField.text = aTexts [i];
myTextField.setTextFormat (myTextFormat);
}
Maybe you are looking for
-
I'm getting copies of all sent items
I've got Microsoft and google accounts more I also checked my ISP account and all do. Once I sent an item if I check sent items there are always two identical messages there. I am running Linux Mint, but I had the same problem under OpenSuse as well.
-
Where can take the source of the page in the new versions?
New versions (after version 5.0), we found the way to take the sources of Web pages page.
-
photosmart HP 5520 and 6520 there removable heads
as the topic-
-
H520 Lenovo graphics card update
Hello I have a H520 with raeadon i7-3770 and amd HD 8570 (OEM), I can change the graphics amd for a GTX 650 or 750? without changing the PSU, also this PSU is a hunting with 240W key which is enough? and btw is has sufficiently pins. I never change o
-
Best practices - dynamic distribution of VI with LV2011
I'm the code distribution which consists of a main program that calls existing (and future) vi dynamically, but one at a time. Dynamics called vi have no input or output terminals. They run one at a time, in a subgroup of experts in the main program.