Namespace in xml element

I have an xml file tagged with namespaces:
for example, ce:section, ce:para
i just trying to collect the 'ce:floats' xml nodes by using the following code:
//Defining the Namespace in the array of arrays of 2 strings
Dim NmSpArr(,) As String = {{"sb", "http://www.elsevier.com/xml/common/struct-bib/dtd"}, {"cl", "http://xml.cengage-learning.com/cendoc-core"}, {"ce", "http://www.elsevier.com/xml/common/dtd"}, {"aid", "http://ns.adobe.com/AdobeInDesign/4.0/"}, {"aid5", "http://ns.adobe.com/AdobeInDesign/5.0/"}, {"xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"}, {"xmlns:mml", "http://www.w3.org/1998/Math/MathML"}, {"xmlns:xlink", "http://www.w3.org/1999/xlink"}}
//Trying to collect the 'ce:floats'
Dim obj As InDesign.Objects = IndDoc.XMLElements(1).EvaluateXPathExpression("//ce:floats", NmSpArr)
ID CS4
Vb.net
Above code always returning 0 as count. It seems there is problem with the xml namespaces definition.
Any help would be greately appreciated.
Regards,
Suresh

Suresh:
Is there anyone know any alternative methods to collect the xml nodes with namespaces?
Again, I wrote:
But it shouldn't be too much work to just traverse the tree.
Here's an example in JavaScript. It should be easy to translate it into VB. Of course all you need is the traverse() function -- the rest is just examples and test cases:
(function() {
  var
    x = app.activeDocument.xmlElements[0],
    star, all, floats, cefloats, anyfloats;
    function traverse(t, p) {
        var r = [], i;
        if (p(t)) {
            r = r.concat(t);
        for (i=0; i<t.xmlElements.length; i++) {
            r = r.concat (traverse(t.xmlElements[i], p));
        return r;
    function dumplist(l) {
        var i,
            rv = [];
        rv.push("has "+l.length+" elements:");
        for (i=0; i<l.length; i++) {
            rv.push("  "+i+"\t"+l[i].toSpecifier()+
                "\t"+l[i].markupTag.name);
        return rv.join("\n");
  star = x.evaluateXPathExpression("*");
  all = traverse(x,
      function() { return true; }
  floats = traverse(x,
       function(n) { return n.markupTag.name==="float"; }
  cefloats = traverse(x,
      function(n) { return n.markupTag.name==="ce:float"; }
  anyfloats = traverse(x,
      function(n) { return n.markupTag.name.match(/float$/); }
  $.writeln("star: "+dumplist(star));
  $.writeln("all "+dumplist(all));
  $.writeln("floats "+dumplist(floats));
  $.writeln("cefloats "+dumplist(cefloats));
  $.writeln("anyfloats "+dumplist(anyfloats));
So, if you run this on a document with an XML schema like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root>
  <ce:float>A</ce:float>
  <ce:float>B</ce:float>
  <float>AC</float>
  <float>Ad</float>
  <ce:float>Af</ce:float>
  <div>
    <ce:float>Ai</ce:float>
    <float>Ag</float>
  </div>
</Root>
It gives you this output:
star: has 3 elements:
  0     /document[@id=1]/XML-element[@id=2]/XML-element[@id=5]     float
  1     /document[@id=1]/XML-element[@id=2]/XML-element[@id=6]     float
  2     /document[@id=1]/XML-element[@id=2]/XML-element[@id=11]     div
all has 9 elements:
  0     /document[@id=1]/XML-element[0]     Root
  1     /document[@id=1]/XML-element[0]/XML-element[0]     ce:float
  2     /document[@id=1]/XML-element[0]/XML-element[1]     ce:float
  3     /document[@id=1]/XML-element[0]/XML-element[2]     float
  4     /document[@id=1]/XML-element[0]/XML-element[3]     float
  5     /document[@id=1]/XML-element[0]/XML-element[4]     ce:float
  6     /document[@id=1]/XML-element[0]/XML-element[5]     div
  7     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[0]     ce:float
  8     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[1]     float
floats has 3 elements:
  0     /document[@id=1]/XML-element[0]/XML-element[2]     float
  1     /document[@id=1]/XML-element[0]/XML-element[3]     float
  2     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[1]     float
cefloats has 4 elements:
  0     /document[@id=1]/XML-element[0]/XML-element[0]     ce:float
  1     /document[@id=1]/XML-element[0]/XML-element[1]     ce:float
  2     /document[@id=1]/XML-element[0]/XML-element[4]     ce:float
  3     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[0]     ce:float
anyfloats has 7 elements:
  0     /document[@id=1]/XML-element[0]/XML-element[0]     ce:float
  1     /document[@id=1]/XML-element[0]/XML-element[1]     ce:float
  2     /document[@id=1]/XML-element[0]/XML-element[2]     float
  3     /document[@id=1]/XML-element[0]/XML-element[3]     float
  4     /document[@id=1]/XML-element[0]/XML-element[4]     ce:float
  5     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[0]     ce:float
  6     /document[@id=1]/XML-element[0]/XML-element[5]/XML-element[1]     float

Similar Messages

  • Namespace specifcation in XML Element

    I need to create an xml file whith namespace specifications on the first XML Element.(sample below) Is there any function provided by the Oracle XML Java Utility that supports this?
    Sample:::::::::::::::::::::::::::::::::::::::::::::::
    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;Submission xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="layout.xsd"&gt;
    &lt;REST OF THE XML&gt;
    &lt;/Submission&gt;

    Never mind. I got it in the meanwhile.

  • Problem using namespace of XML docs gerenrated by  XMLForm

    Hi community!
    I am facing a problem using namespace within a XSL stylsheet. Let me describe my problem:
    I am using the SAP XMLFormsBuilder within the SAP EnterprisePortal in order to provide a HTML based form for creating and editing specific XML documents. The data in the generated documents is finally presented as HTML using XSL Transformation.
    In the XMLFormsBuilder you define the Schema of the XML document and the HTML GUI of the form. The Schema document looks like below (extract):
    <?xml version="1.0" encoding="utf-8"?>
    <schema targetNamespace="http://www.xmlspy.com/schemas/orgchart"
            xmlns="http://www.w3.org/2001/XMLSchema"
            xmlns:xyz="http://www.xmlspy.com/schemas/orgchart" Version="6.3.0">
      <element name="commodity"
               default=""
               minOccurs="1"
               maxOccurs="1"
               ns="p2p"
               xmlns:p2p="http://www.portal.p2p.com">
        <complexType>
          <sequence>
            <element name="administrative_information"
                     default=""
                     minOccurs="1"
                     maxOccurs="1"
                     ns="p2p">
              <complexType>
                <sequence>
                  <element name="creation_date"
                           default=""
                           minOccurs="1"
                           maxOccurs="1"
                           type="date"
                           ns="p2p"/>
    As far as I understand, each element defined in the Schama belongs to the namespace "p2p" and this is exactly what I want.
    The XML document generated by the form looks like below (extract):
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="show_card.xsl"?>
    <commodity xmlns:xf="http://www.sapportals.com/wcm/app/xmlforms"
               xmlns:xsi="http//www.w3.org/2001/XMLSchema-instance"
               xsi:noNamespaceSchemaLocation="/etc/xmlforms/P2PCategoryCard_TEST/P2PCategoryCard_TEST-Schema.xml">
      <administrative_information>
        <creation_date>2005-07-04</creation_date>
    Consequently, the file "show_card.xsl" is the responsible XSLT stylesheet, which looks like this:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:p2p="http://www.portal.p2p.com">
      <xsl:output method="html"/>
      <xsl:template match="p2p:commodity">
        <html>
        <body>
          <h2>XSLT Test</h2>
          Creation Date: <xsl:value-of select="p2p:administrative_information/p2p:creation_date"/>
        </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>
    The problem in the XSLT stylesheet is, that I want to access the XML document elements using their namespace. And this is exactly what does not work for me. On the other hand, if I remove the reference to the namespace:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:p2p="http://www.portal.p2p.com">
      <xsl:output method="html"/>
      <xsl:template match="commodity">
        <html>
        <body>
          <h2>XSLT Test</h2>
          Creation Date: <xsl:value-of select="administrative_information/creation_date"/>
        </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>
    the stylesheet works fine, but for some technical reasons, which I don't want to explain here, I have to use the namespace when accessing the XML document elements.
    For technical reasons, I cannot change the format of the Schema document and also cannot change the format of the generated XML document. The only file I can change and control is the XSLT stylsheet.
    My question is now, in the case described above, if there is any way to use the namespace in the sytlesheet when accessing the XML elements?
    Any help is appreciated.
    Cheers,
    Adam Kreuschner

    duggal.ashish wrote:
    3. Some XML files contain a "iso-8859-1" character with character code 146 which appears like apostrophes but actually it is : - &#146; and the problem is that words like can&#146;t are shown as can?t by database.http://en.wikipedia.org/wiki/ISO8859-1
    Scroll down in that page and you'll see that the character code 146 -- which would be 92 in hexadecimal -- is in the "unused" area of ISO8859-1. I don't know where you got the idea that it represents some kind of apostrophe-like character but it doesn't.
    Edit: Actually, I do know where you got that idea. You got it from Windows-1252:
    http://en.wikipedia.org/wiki/Windows-1252
    Not the same charset at all.

  • NS0 namespace in every element after mapping

    Hi All,
    We have a scenario IDOC --> XML file on a file share. I created a free style data type for the XML message and the mapping objects. When I test the message mapping, every XML element gets the ns0 namespace before the tagname. The namespace prefix is ok to be mentioned on a root level, but not with every element. Can we configure something that this behavior is not occuring anymore?
    Example current result:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:OrderCreateNotification xmlns:ns0="urn:mc-nl:procurement:boras:boras">
    <ns0:OrderNumber>4550000037</ns0:OrderNumber>
    <ns0:DocumentDate>20140722</ns0:DocumentDate>
    <ns0:OrderItem>
         <ns0:ItemNumber>00001</ns0:ItemNumber>
         <ns0:Unit>ST</ns0:Unit>
         <ns0:Quantity>100.000</ns0:Quantity>
         <ns0:NettPrice>10000</ns0:NettPrice>
         <ns0:PurchaseRequisitionItemNumber>00000</ns0:PurchaseRequisitionItemNumber>
         <ns0:TaxRate>21.00</ns0:TaxRate>
    </ns0:OrderItem>
    </ns0:OrderCreateNotification>
    I expected to have it like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:OrderCreateNotification xmlns:ns0="urn:mc-nl:procurement:boras:boras">
    <OrderNumber>4550000037</OrderNumber>
    <DocumentDate>20140722</DocumentDate>
    <OrderItem>
         <ItemNumber>00001</ItemNumber>
         <Unit>ST</Unit>
         <Quantity>100.000</Quantity>
         <NettPrice>10000</NettPrice>
         <PurchaseRequisitionItemNumber>00000</PurchaseRequisitionItemNumber>
         <TaxRate>21.00</TaxRate>
    </OrderItem>
    </ns0:OrderCreateNotification>
    With the data type it is possible to define the property "qualify schema", but it doesn't seem to do anything.
    I know of the possibility to use the XML Anonimizer module, but I was hoping that we can configure this in a standard way.
    kind regards,
    Mark

    Hi All,
    Issue was solved by defining the value "None" in the Qualify Schema option + reimporting the message types into the message mapping after making the Qualify Schema change. The XML structures didn't got refreshed automatically.
    Everything is working normally now with the ns prefix only on root level.
    Regards,
    Mark

  • How to remove namespace from root-element

    Hi Gurus,
    I want one xml output from xslt transformation with no namespace. I managed to remove namespace from child elements by leveraging elementFormDefault ='unqualified' property of xsd. But not able remove namespace from root-element.
    Output that I want is :
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <inp1:Email_Mod_Root>
       <Email_Mod_Root_Element>
          <Email_Record1>
             <PERSON_NUMBER>123456</PERSON_NUMBER>
             <COUNTRY/>
              <EMAIL_TYPE>WORK</EMAIL_TYPE>
             <EMAIL>EMAIL3</EMAIL>
             <PRIMARY_FLAG>Y</PRIMARY_FLAG>
          </Email_Record1>
    </Email_Mod_Root_Element>
    </Email_Mod_Root>
    Output that I am getting:
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <inp1:Email_Mod_Root xmlns:inp1="http://www.example.org">
       <Email_Mod_Root_Element>
          <Email_Record1>
             <PERSON_NUMBER>123456</PERSON_NUMBER>
             <COUNTRY/>
             <EMAIL_TYPE>WORK</EMAIL_TYPE>
             <EMAIL>EMAIL3</EMAIL>
             <PRIMARY_FLAG>Y</PRIMARY_FLAG>
          </Email_Record1>
    </Email_Mod_Root_Element>
    </Email_Mod_Root>
    Anyone, pls suggest.
    Thanks in advance,
    SG_SOA

    First of all :
    <inp1:Email_Mod_Root>
       <Email_Mod_Root_Element>
          <Email_Record1>
             <PERSON_NUMBER>123456</PERSON_NUMBER>
             <COUNTRY/>
              <EMAIL_TYPE>WORK</EMAIL_TYPE>
             <EMAIL>EMAIL3</EMAIL>
             <PRIMARY_FLAG>Y</PRIMARY_FLAG>
          </Email_Record1>
    </Email_Mod_Root_Element>
    </Email_Mod_Root>
    isn't valid xml (you start with inp1: prefix and you end the tag with no prefix, but let's assume you don't want any prefix/namespace at all)
    if i use :
    [code]
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:inp1="http://www.example.org" exclude-result-prefixes="inp1">
      <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="*">
        <xsl:element name="{local-name(.)}">
          <xsl:apply-templates select="@* | node()"/>
        </xsl:element>
      </xsl:template>
      <xsl:template match="@*">
        <xsl:attribute name="{local-name(.)}">
          <xsl:value-of select="."/>
        </xsl:attribute>
      </xsl:template>
    </xsl:stylesheet>
    [/code]
    i get this
    [code]
    <Email_Root_Element>
      <Email_Record>
      <EMPLID>EMPLID46</EMPLID>
      <EMAIL>EMAIL48</EMAIL>
      <E_ADDR_TYPE>E_ADDR_TYPE49</E_ADDR_TYPE>
      <COUNTRY>US</COUNTRY>
      </Email_Record>
      <Email_Record>
      <EMPLID>EMPLID47</EMPLID>
      <EMAIL>EMAIL49</EMAIL>
      <E_ADDR_TYPE>E_ADDR_TYPE50</E_ADDR_TYPE>
      <COUNTRY>US</COUNTRY>
      </Email_Record>
      <Email_Record>
      <EMPLID>EMPLID48</EMPLID>
      <EMAIL>EMAIL49</EMAIL>
      <E_ADDR_TYPE>E_ADDR_TYPE51</E_ADDR_TYPE>
      <COUNTRY>US</COUNTRY>
      </Email_Record>
    </Email_Root_Element>
    [/code]

  • How to remove prefix namespace in Xml from XmlBean

    I am trying to generate XML from XML Bean but i am getting namespace prefix in all my xml elements.
    For example
    <abc:Cutomer xmlns:abc="http://www.xyz.com/pqr>
    <abc:Name>
    I don't have this namespace prefix in my XSD (imported in Weblogic workshop).
    Is there any way that I can remove this prefix from my xml elements?
    Also, I don't need xml namespace in my xml string.
    Is there any way that I can generate xml without having namespace?

    Hello ,
    I think this issue as been discussed earlier in this forum. Refer follwoing link..
    http://forums.bea.com/bea/message.jspa?messageID=400000090#400000090
    Regards,
    Kuldeep Singh.

  • Jaxp namespaces in document elements

    I am trying to use Java to access xml items using XPath.
    I am OK with an xml document with name spaces in root element.
    But not namespaces declared in elements.
    Typically see two documents at
    http://www.w3schools.com/XML/xml_namespaces.asp
    Under
    XML Namespaces - The xmlns Attribute
    Quote "Namespaces can be declared in the elements where they are used or in the XML root element:"
    My Xpath is "/root/h:table/h:tr/h:td"
    This works OK for second document with namespaces in root element.
    But not the first document with namespaces in the elements.
    I have tried using lookupNamespaceURI but this only seems to process root element.
    It's hair pulling time!
    Any Ideas
    Thanks

    OK messy but ..
    Set the line
    XPathDemo xPathDemo = new XPathDemo("C:/opt/XpathDemo/w32.XML");to be either of the two w3schools example quoted previously.
    import java.io.File;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Iterator;
    import javax.xml.XMLConstants;
    import javax.xml.namespace.NamespaceContext;
    import javax.xml.parsers.DocumentBuilder;  
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.xpath.XPath;
    import javax.xml.xpath.XPathConstants;
    import javax.xml.xpath.XPathExpression;
    import javax.xml.xpath.XPathExpressionException;
    import javax.xml.xpath.XPathFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class XPathDemo
        public class UniversalNamespaceResolver implements NamespaceContext
            // the delegate
            private Document sourceDocument;
             * This constructor stores the source document to search the namespaces in it.
             * @param document source document
            public UniversalNamespaceResolver(Document document)
                sourceDocument = document;
             * The lookup for the namespace uris is delegated to the stored document.
             * @param prefix to search for
             * @return uri
            public String getNamespaceURI(String prefix)
                String retVal;
                if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX))
                    retVal = sourceDocument.lookupNamespaceURI(null);
                else
                    retVal = sourceDocument.lookupNamespaceURI(prefix);
                return retVal;
             * This method is not needed in this context, but can be implemented in a similar way.
            public String getPrefix(String namespaceURI)
                return sourceDocument.lookupPrefix(namespaceURI);
            public Iterator getPrefixes(String namespaceURI)
                // not implemented yet
                return null;
        public XPathDemo(String fileName)
            try
                String dataFileName = "C:/opt/XpathDemo/tmp.txt";
                File f = new File(dataFileName);
                PrintWriter out = new PrintWriter(f);
                generateData(out, fileName);
                out.flush();
                out.close();
            catch (XPathExpressionException xp)
                System.out.println("Exception expression cannot be compiled : " + xp.getMessage());
            catch (NullPointerException np)
                System.out.println("expression is null : " + np.getMessage());
            catch (Exception e)
                System.out.println("General exception : " + e.getMessage());
        public void generateData(PrintWriter out, String fileName) throws ParserConfigurationException, SAXException, IOException,
            XPathExpressionException
            DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
            domFactory.setNamespaceAware(true); // never forget this!
            DocumentBuilder builder = domFactory.newDocumentBuilder();
            Document doc = builder.parse(fileName);
            XPathFactory factory = XPathFactory.newInstance();
            XPath xpath = factory.newXPath();
            xpath.setNamespaceContext(new UniversalNamespaceResolver(doc));
            System.out.println("Setting expr");
            XPathExpression expr = xpath.compile("/root/h:table/h:tr/h:td");
            if (expr != null)
                Object result = expr.evaluate(doc, XPathConstants.NODESET);
                if (result != null)
                    NodeList nodes = (NodeList) result;
                    System.out.println("Looping through " + nodes.getLength());
                    for (int i = 0; i < nodes.getLength(); i++)
                        System.out.println("i = " + i);
                        Node thisNode = nodes.item(i);
                        NodeList thisNode2 = thisNode.getChildNodes();
                        Node xx = thisNode2.item(0);
                        String val = xx.getNodeValue();
                        System.out.println("Value : '" + val + "'");
                else
                    System.out.println("Result was NULL");
            else
                System.out.println("Expr was NULL");
        public static void main(String[] args)
            XPathDemo xPathDemo = new XPathDemo("C:/opt/XpathDemo/w32.XML");
            System.out.println("Main complete!");
    }

  • Deleting XML element in ABAP mapping

    hi All
    I Have I huge xml filen that has to go to an Idoc , but I only want to use the header data.
    is there a way of deleting the unwanted xml elements and their children elements in ABAP mapping.
    Thanks.

    Hi Ravi and all
    Actually I did as you said, but I get this error.
    <Trace level="1" type="T">com.sap.aii.utilxi.misc.api.BaseRuntimeException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException:
    XMLParser: Prefix 'ns1' is not mapped to a namespace(:main:, row:177, col:25)
    This position 177 , is the element that is not needed , so I thought if I can delete it , I can get rid of this error and move forward.
    May be you have antoher suggestion to get rid of this error.
    Thank you.

  • How to remove namespace from xml in ALSB?

    I have a xquery transformation which works for data without namespace. But the data coming from source system has namespace details in it. Is there a way to strip the xml of namespace details from xml before passing it to xquery transformation?

    Hi
    silly mistake :P
    Following 'bold' declaration was not there!!
    Just copy paste following code as xquery and it will be all ok:
    declare namespace xf = "http://tempuri.org/vijfhuizen/com/myMessage/";
    declare function xf:strip-namespace($e as element())
    as element()
    element { xs:QName(local-name($e)) }
    for $child in $e/(@*,node())
    return
    if ($child instance of element())
    then xf:strip-namespace($child)
    else $child
    declare variable $e as element() external;
    xf:strip-namespace($e)

  • How to access XML elements by name in Extendscript??

    I'm almost done the script that I've been working on, but something has been nagging me since I started. When I did start, I looked at the JS Tools Guide CS5 that comes with the extendscript ide to check how to access XML elements, children, attributes etc. It says this:
    The XML object represents an XML element node in an XML tree. The topmost XML object for an XML file
    represents the root node. It acts as a list, which contains additional XML objects for each element. These in
    turn contain XML objects for their own member elements, and so on.
    The child elements of an element tree are available as properties of the XML object for the parent. The
    name of the property corresponds to the name of the element. Each property contains an array of XML
    objects, each of which represents one element of the named type.
    So basically it converts the XML into JSON. And you can access the properties like so:
    <book category="COOKING">
         <title lang="en">The Boston Cooking-School Cookbook</title>
         <author>Fannie Merrit Farmer</author>
         <year>1896</year>
         <price>49.99</price>
    </book>
    The Javascript statement bookstoreXML.book; returns the entire list of books.
    The statement bookstoreXML.book[0]; returns the XML object for the first book.
    The statement bookstoreXML.book[0].author; returns all authors of the first book.
    A couple pages down it talks about Retrieving contained elements using children(), elements(), descendants().
    So now I look through the XML Object properties and I see that I can use:
    xmlObj.child (which) which A String, the element name, or a Number, a 0-based index into this node’s child array.
    or
    xmlObj.descendants ([name])
    name Optional. A String, the element name to match. If not provided, matches all
    elements.
    or
    xmlObj.elements (name);
    name Optional. A String, the element name to match. If not provided, matches all
    elements.
    This is an excerpt of an XML I was working with:
    <ROW xmlns="http://www.filemaker.com/fmpdsoresult"
         MODID="16"
         RECORDID="11128">
       <Sign_Type>251.dr</Sign_Type>
       <fm:Location xmlns:fm="http://www.filemaker.com/fmpdsoresult" xmlns="">5-5024</fm:Location>
       <Line1>Zone
    Floor
    3
    Patient Rooms
    R532 - R436 even
    Patient Rooms
    R522 - R446 even
    Xavier Elevators
    Zone
    Patient Rooms
    R537 - 5757 odd
    Main Elevators
    Zone</Line1>
    </ROW>
    Extendscript will not give me an anything when I try to access elements by name. Instead I have to access by index, which works, but I'd rather search for names!
    Actually the console log returns: <![CDATA[]]>
    What am I doing wrong!?

    First, those E4X XML objects are definitely no JSON (plain data) - they have a multitude of methods, even for tasks that would easily be implemented as property (e.g. the length() function), and they also bind xml element and attribute names onto the objects, allowing to target a multitude of XML nodes with a single statement. Or did you mean your script with that "it"?
    Anyway, as you found out the ExtendScript XML object handles namespaces mostly by hiding them from you.
    You could play around with global namespace settings, see the JavaScript tools guide.
    You could also explicitly specify a namespace. This works for me:
    $.writeln(myXML["fm:Location"]);
    For simple use I had most success with a brute force approach that just strips the namespaces.
    function removeAllNamespace(xml)
              var ns =new Namespace();
              var d=xml.descendants();
              for (var i=0;i<d.length();i++)
        d[i].setNamespace(ns);

  • XML tag markers moved: Find and Replace causing problem in xml elements

    Hi All,
    I am doing find and replace using GREP. While using the expression like $1, $2 (Found Items) in the change to field it changes the placement of tag marker. If the found item is a part of two of more xml elements, I am getting a serious problem while replacing it. (ie. The xml tag markers are moved.)
    See the screen shot below, then you may get better idea. And help me to overcome this issue.
    This is just an example to show you what i'm trying to say, there are so many cases like this.
    Original text/ Before doing find replace
    After replacing
    Green4ever

    Hi Peter and John,
    but it seems to me that the example is looking for any space that
    follows a semi-colon and has two word characters following it, and
    repalce that with an em space. I think you could do the same using look
    behind and look ahead and not need to replace the found text.
    Yes you are right about the look behind and look ahead. I'd like to show some more examples to show what the actual problem is,
    Original/Before Replacing,
    (Consider there is another case here, instead of em-space some times normal word space will also be there)
    Using the Grep:
    Find What---------> ^(\d+\.(?:\d+)?)~m
    Change To------------->$1\t
    After Replace:
    Did I make any sense? Eventhough this will not make any changes in the layout, my requirement is to insert the tab out-side the tag marker not indise.
    Green4ever

  • How can we get the reference of XML element on frame as soon as frame is created in Document?

    Hi,
    When ever we copy any text/table cells from any frame, and paste it directly on page, A new Frame is created and the pasted text is placed inside that frame.
    Now to capture this frame creation, We have two possible solutions:
    1) Attach Observer on Document 'kDocBoss' on IID_IHIERARCHY_DOCUMENT and it will notify on frame creation in update function.
    2) Notification event on new story creation.
    Now, I need to perform some changes in the newly created table, for example:
    a)  Need to delete XML tags from newly created frame
    b)  Need to perform action on table cells if any in the created frame.
    But the problem is, when the event comes, I can access basic properties of frame like it's name, type etc, but it does not give me the
    XML element on frame or tables in frame until the event is com pleat.
    I know it's quite a specif requirement, but I guess many of you might have faced these kind of challenges, while processing the event.
    Does any one has any idea how I can get the reference of XML element on frame as soon as it is created?

    Hi Kapoor,
    please give also others a chance, and excuse that I get up late on vacation ;-)
    Anyway, I'd keep the story creation responder to recognize the copy, then combine it with an observer on the backing xml story to catch the associated XML element which is created there. Something like below:
    UIDRef xmlStoryRef = Utils<IXMLUtils>()->GetBackingStore(doc);
    InterfacePtr<ISubject> subject ( xmlStoryRef,IID_ISUBJECT );
    subject->AttachObserver(observer,IID_IIDXMLELEMENT,observer->GetAttachIID());

  • Hiding XML elements in the structure view – scripting influence to the structure view?

    Hi
    Is there a way to hide specific XML elements (really the elements and not the attributes) in the structure view?
    I am asking this question to know if it is possible to influence the structure view by scripting.
    Many elements are indeed used as a kind of help for constructions which have nothing to do with the actual contents especially in the case of tables.
    You inflate the the structure view unnecessarily and the author will lose track of the real contents. It would be nice if there was a possibility to hide those help construction elements.
    Thank you for any hints.
    Regards
    Apollo102

    Hello Apollo,
    There is a way to hide elements from the Structure View (one such method is offered by the free AXCM plug-in). What happens when you use AXCM (or other methods to hide elements) is that the elements get wrapped into hidden content. This might make the structure view less complex for your authors, but has a number of disadvantages and dangers.
    1. The structure is normally invalidated, as the helper elements are usually required.
    2. Accidentally deleting hidden content may make the invalidation permanent and render your documents useless.
    It is NOT good practice to hide elements from authors in the structure view. Instead, you should either teach authors about the structure, or let them work in the Author View while adding sufficiently clear formatting to show them the underlying structure. In some cases, it might be better to create an authoring structure which is automatically transformed into the required full structure using an XSLT or other processing step. I have created a couple of such environments and they work fine. It just depends on the difference between the structure required for further processing and the structure that would be optimal for your authors (which in turn depends on the level at which your authors are experienced in working with structured content).
    I hope this helps you solve your problem without having to tweak the structure view.
    Kind regards
    Jang

  • Error While trying to Get XML element(tag) Values

    We are trying to get XML element (TAG) value from the XML pay load.
    Example.
    Getting XML String from a web service and then converting into XML payload.
    ora:parseEscapedXML(bpws:getVariableData('signOn_Out','signOnReturn'))
    From this XML payload we are trying to get an element (Tag) value.
    We are getting following error
    Error in evaluate <from> expression at line "130". The result is empty for the XPath expression : "/client:TririgaProcessResponse/client:User/client:LastName".
    oracle.xml.parser.v2.XMLElement@118dc2a
    {http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.
    - <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    - <part name="summary">
    <summary>
    empty variable/expression result.
    xpath variable/expression expression "/client:TririgaProcessResponse/client:User/client:LastName" is empty at line 130, when attempting reading/copying it.
    Please make sure the variable/expression result "/client:TririgaProcessResponse/client:User/client:LastName" is not empty.
    </summary>
    </part>
    </selectionFailure>
    Here are signOnReturn and XML Payload XSD's
    <schema attributeFormDefault="unqualified"
         elementFormDefault="qualified"
         targetNamespace="http://xmlns.oracle.com/Web1"
         xmlns="http://www.w3.org/2001/XMLSchema">
         <element name="Web1ProcessRequest">
              <complexType>
                   <sequence>
                        <element name="userName" type="string"/>
    <element name="password" type="string"/>
                   </sequence>
              </complexType>
         </element>
         <element name="Web1ProcessResponse">
              <complexType>
                   <sequence>
                        <element name="result" type="string"/>
                   </sequence>
              </complexType>
         </element>
    </schema>
    <?xml version="1.0" encoding="windows-1252" ?>
    <schema attributeFormDefault="unqualified"
         elementFormDefault="qualified"
         targetNamespace="http://xmlns.oracle.com/Web"
         xmlns="http://www.w3.org/2001/XMLSchema">
         <element name="TProcessResponse">
              <complexType>
                   <sequence>
                        <element name="result" type="string"/>
    <element name="User">
    <complexType>
                   <sequence>
                        <element name="Id" type="string"/>
    <element name="CompanyId" type="string"/>
    <element name="SecurityToken" type="string"/>
    <element name="FirstName" type="string"/>
    <element name="LastName" type="string"/>
    </sequence>
    </complexType>
    </element>
                   </sequence>
              </complexType>
         </element>
    </schema>

    I am sure and can see the data in audit trail.
    [2006/12/12 09:17:36]
    Updated variable "signOn_Output"
    - <signOn_Output>
    - <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
    - <WebMethodsProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
    <Result xmlns="">
    Success
    </Result>
    - <User xmlns="">
    <Id>
    2694069
    </Id>
    <CompanyId>
    208133
    </CompanyId>
    <SecurityToken>
    1165936654605
    </SecurityToken>
    <FirstName>
    Jagan
    </FirstName>
    <LastName>
    Rao
    </LastName>
    </User>
    </WebMethodsProcessResponse>
    </part>
    </signOn_Output>
    Copy details to clipboard
    [2006/12/12 09:17:36]
    Updated variable "tririga"
    - <tririga>
    - <TririgaProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
    <Result xmlns="">
    Success
    </Result>
    - <User xmlns="">
    <Id>
    2694069
    </Id>
    <CompanyId>
    208133
    </CompanyId>
    <SecurityToken>
    1165936654605
    </SecurityToken>
    <FirstName>
    Jagan
    </FirstName>
    <LastName>
    Rao
    </LastName>
    </User>
    </TririgaProcessResponse>
    </tririga>
    Copy details to clipboard
    [2006/12/12 09:17:36]
    Updated variable "Variable_2"
    - <Variable_2>
    - <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
    - <TririgaProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
    <Result xmlns="">
    Success
    </Result>
    - <User xmlns="">
    <Id>
    2694069
    </Id>
    <CompanyId>
    208133
    </CompanyId>
    <SecurityToken>
    1165936654605
    </SecurityToken>
    <FirstName>
    Jagan
    </FirstName>
    <LastName>
    Rao
    </LastName>
    </User>
    </TririgaProcessResponse>
    </part>
    </Variable_2>
    Copy details to clipboard
    [2006/12/12 09:17:36]
    Error in evaluate <from> expression at line "130". The result is empty for the XPath expression : "/client:TririgaProcessResponse/client:User/client:LastName".
    oracle.xml.parser.v2.XMLElement@1c8768e
    Copy details to clipboard
    [2006/12/12 09:17:36]
    "{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.
    - <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    - <part name="summary">
    <summary>
    empty variable/expression result.
    xpath variable/expression expression "/client:TririgaProcessResponse/client:User/client:LastName" is empty at line 130, when attempting reading/copying it.
    Please make sure the variable/expression result "/client:TririgaProcessResponse/client:User/client:LastName" is not empty.
    </summary>
    </part>
    </selectionFailure>
    Copy details to clipboard

  • How to find out the page number of an xml element

    Hi everybody, sorry for my very bad english (french guy! logical). I hope you see what I'm looking for.
    I'm scripting (javascript) an exporting script of every articles from a multi-pages indesign script.
    In fact I could have one or more article in one file, every one of them is on an separate xml element. for each I have to export an xml file named with, first, the page number where appears the xml element, second, the number of exported article.
    I'm success the second purpose, but not the first.
    Someone have an idea ?

    Try this,
    var myDoc=app.activeDocument;
    var root = myDoc.xmlElements[0];
    var docTag = root.evaluateXPathExpression('//doc');
    for(i=0; i<docTag.length; i++)
        var docPos = docTag[i].insertionPoints.lastItem();
        var docFrame = docPos.parentTextFrames[0];
        var docPage;
        try
             docPage = docFrame.parentPage;
    catch(e)
            docPage = docFrame.parent.name;
        alert(docPage.name);
    Vandy

Maybe you are looking for