Display xml elements

I can read in a file and display the XML elements of 1 tag
(book)but i cant do elements of many tags (all book tags)like this
input from file
<?xml version="1.0" ?>
<books>
<book author="Mmark twain" title="huck finn" />
<book author="mark twain2" title="huck finn2" /> /cant
print out?
</books>
output and no 2nd line from above???
Mmark twain author
huck finn title
AS
var xRootNode:XMLNode =xmlData.firstChild ;
var xnBook:XMLNode =xRootNode.firstChild;
var attrib:Object =xnBook.attributes
for (var sattrib:String in attrib ) {
trace(attrib[sattrib]+ " " + sattrib); //only prints 1 line
of <book> tag and not 2
}

Its the nextSibling of nxBook or, you may want to do it via
an array:
var xRootNode:XMLNode =xmlData.firstChild ;
var xnBooks:XMLNode =xRootNode.childNodes;
for (var j=0;j<xnBooks.length;j++) {
var attrib:Object =xnBooks[j].attributes
for (var sattrib:String in attrib ) {
trace(attrib[sattrib]+ " " + sattrib);

Similar Messages

  • Java XML-Reader (SAX)--How to read and display xml-element-data???

    hello all,
    i would like to display just some xml-data
    Which methods in java should i use to select just one character-data of this (for example: "deu" from the element <Language> or the attribut "version" of the element <catalog>).
    Here is the XML-document i want to parse and display it with System.out.print() :
    <BMECAT version="1.2">
         <HEADER>
              <GENERATOR_INFO>
                   e-proCat 2.1, e-pro solutions GmbH
              </GENERATOR_INFO>
              <CATALOG>
                   <LANGUAGE>deu</LANGUAGE>
                   <CATALOG_ID>Katalog 01</CATALOG_ID>
                   <CATALOG_VERSION>001.000</CATALOG_VERSION>
                   <CATALOG_NAME>ETIM</CATALOG_NAME>
                   <DATETIME type="generation_date">
                        <DATE>2002-05-22</DATE>
                   </DATETIME>
                   <TERRITORY>DE</TERRITORY>
                   <CURRENCY>EUR</CURRENCY>
                   <MIME_ROOT>ETIM-Daten</MIME_ROOT>
              </CATALOG>
    </HEADER>
    </BMECAT>
    Here is the java application i wrote and which doesn t work:
    import org.apache.xerces.parsers.SAXParser;
    import org.xml.sax.Attributes;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.Locator;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
         public class XmlLeser implements ContentHandler {
    public XmlLeser(String fileName) {
    try {
    XMLReader myParser = new SAXParser(); // SAXParser (Xerces)
    myParser.setContentHandler(this);           
    myParser.parse(fileName);      } catch (Exception e) {
         System.out.println("Erreur " + e);     }
    }// End of constructor
    public void startDocument() {
         System.out.println(" start to parse " );
    } // startDocument()
    public void endDocument() {
    System.out.println(" End of Parse ");
    } // endDocument()
    public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
         System.out.println(localName) ;
    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {           
    }// Endelement()
    public void characters(char ch[], int start, int length) {
    } // endCharacters(char[],int,int);
    public void processingInstruction(String target, String data) {
    } // processingInstruction(String,String)
    public void ignorableWhitespace(char ch[], int start, int length) {
              characters(ch, start, length);
    } // ignorableWhitespace(char[],int,int);
    public static void main(String args[]) {
    String xmlFileName = "";
    if (args.length == 0) {               
    System.out.println("Usage::java XmlLeser path/xmlFilename");
    System.exit(0);      } else {
    xmlFileName = args[0];
    XmlLeser pux = new XmlLeser(xmlFileName);
    }// end main()
    }//endClass

    You need to pass your filename String as a parameter to your functionality. It depends how you're currently set up though. We can't really see the top of your call so it's difficult to determine what you are calling and we don't really know from where you're calling either.
    If you're running standalone, then on launch of the application, you can feed in a file name as an argument that you can read in in String args[] in the main function and pass down to your XML splitter.
    If you're a method in a class that's part of a bigger pile, you can feed the file name as a String to the method from wherever you call from if it makes sense architecturally.
    You might also want to pass down a File object if that makes sense in your current code (i.e. if you're using your file for other purposes prior to the split, to avoid recreating closing/opening for no reason).
    Depends what you're trying to do. If I put together a piece like this, I would probably create an <yourcurrentrootpackage>.xml.splitter package.
    Also, on a side note, you're problem isn't really reading and writing XML in java, but seems more to be making your functionality generic so that any XML file can be split with your code.
    Regards
    JFM

  • How to display the total of a particular xml element page wise

    Hello friends,
    My requirement is like I need to display an xml element Margin along with the other elements..Now I want the sum of margin element for each page... how do I do it in the rtf template.. and the end user views it in pdf form...
    thanks in advance

    Can you check the example in http://download.oracle.com/docs/cd/E10415_01/doc/bi.1013/e12187/T421739T481157.htm#4535379
    You can also check an example in your local machine in C:\Program Files\Oracle\BI Publisher\BI Publisher Desktop\samples\RTF templates\Advanced\Page Total

  • Displaying XML Document in new browser window

    Hi,
    I have a hyperlink on my page. When I click on it, it will open a new IE window and display xml document.
    The new window is displaying some of the xml and at the end displaying the following:
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    End element was missing the character '>'. Error processing resource 'http://localhost:28080/benchmark/faces/displayXMLDocu...
    However, I cut and paste the xml String where I write it to the HTTPServletResponse to XMLSPY and it displays correctly.
    Please let me know.
    Rgrds

    Here are the steps:
    1. I created page1 that has a hyperlink.
    2. Hyperlink property are set to display page2 in a new window. (popup).
    3. page2.prerender() method, I set the response to the following:
    public void prerender() {
    javax.faces.context.ExternalContext ec = this.getExternalContext();
    HttpServletResponse response = (HttpServletResponse)ec.getResponse();
    response.setHeader("Cache-Control","no-cache");
    response.setHeader("Cache-Control","no-store");
    response.setHeader("Cache-Control","must-revalidate");
    response.setHeader("Cache-Control","max-age=0");
    response.setHeader("Pragma","no-cache");
    response.setHeader("Expires","0");
    response.setContentType("text/xml");
    response.setBufferSize(5000);
    String xmlString = getRequestBean1().getBookingPnrDetailsXML();
    try{
    xmlString="<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><test1>this is a test</test1><victor>Hello Victor</victor></root>";
    PrintWriter out = new PrintWriter(response.getOutputStream());
    log(xmlString);
    out.print(xmlString);
    }catch(IOException io){
    System.out.println("" + io.getMessage());
    io.printStackTrace();
    4.page2.jsp code is the following:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui">
    <jsp:directive.page contentType="text/xml;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view/>
    <ui:page binding="#{displayXMLDocument.page1}" id="page1"/>
    <ui:html binding="#{displayXMLDocument.html1}" id="html1"/>
    <ui:head binding="#{displayXMLDocument.head1}" id="head1"/>
    <ui:link binding="#{displayXMLDocument.link1}" id="link1"/>
    <ui:body binding="#{displayXMLDocument.body1}" id="body1"/>
    <ui:form binding="#{displayXMLDocument.form1}" id="form1"/>
    </jsp:root>
    please let me know.
    Rgrds.

  • Carriage Returns and Tabs in XML element

    I have a number of carriage returns and tabs within an xml element. When I take that element I would like it to transform to html in which I am then displaying within a JEditorPane. However, when I do this it is one long string. I have tried the xml:space="preserve" within that element and this still is not working.
    Here is part of the xml with the carriage return line feeds. The element that I am talking about is called pseudocode. You can see it is displayed correctly below.
    Design Document XML : <?xml version="1.0" encoding="ISO-8859-1"?><design-doc><title-page><title>Testing Document</title><class-prepared-for>Lloyd</class-prepared-for><authors>Ben Garbers</authors><date-created>September 23, 2004</date-created></title-page><introduction text="This is the introduction. This is the introduction."/><class-definitions><class-definition class-name="ClassOne" visibility="public" class-complexity="not complex"><global-variables><variable visibility="public" name="VariableOne" object="String" comments="This is a String."/><variable visibility="public" name="VariableTwo" object="Integer" comments="This is an Integer."/></global-variables><methods><method name="MethodOne" synopsis="This will do some things." purpose="public" visibility="public"><input-parms><variable visibility="null" name="firstName" object="String" comments="null"/></input-parms><output-parms><variable visibility="null" name="lastName" object="String" comments="null"/></output-parms><local-variables><variable visibility="null" name="age" object="int" comments="null"/></local-variables><pseudocode xml:space="preserve">/* Ensure that player name exist in the system*/
    if (player =null)
         NullPlayerException;
              if (NOT (isPlayerNameExist(player)))
                   throw PlayerNameNotExistException;
              /* Ensure player name exist in the team already*/
              i ? 1;
              while (i <= length(mPlayers)) {
                   if (mPlayers.mPlayerName != playerName)
                        throw PlayerNameNotExistInTeamException;
    this.mPlayers ? this.mPlayers - player;</pseudocode>
    However, when I do the transformation I get the following with the pseudocode:
    /* Ensure that player name exist in the system*/if (player =null)     NullPlayerException;          if (NOT (isPlayerNameExist(player)))               throw PlayerNameNotExistException;          /* Ensure player name exist in the team already*/          i ? 1;          while (i <= length(mPlayers)) {               if (mPlayers[i].mPlayerName != playerName)                    throw PlayerNameNotExistInTeamException;}this.mPlayers ? this.mPlayers - player;
    It looks like it adds some spaces but no carriage returns or line feeds.
    My transformation code is the following:
         public ParseFile(String xmlString) {
              try {
              //Here we will load the correct style sheet for the message
              //that will be formatted.
              String urlString = "DesignDocument.xsl";
              URL url = this.getClass().getResource(urlString);
              System.out.println("URL to style sheet = " + url.toString());
              String styleSheetName = url.getFile();
              System.out.println("Style sheet name : " + styleSheetName);
              InputStream styleSheetInputStream = this.getClass().getResourceAsStream(urlString);
              //We will than load our SAXParerFactory and parse the message.
              SAXParserFactory SPFactory = SAXParserFactory.newInstance();
              SPFactory.setValidating(true);
              SAXParser sp = SPFactory.newSAXParser();
              XMLReader sax2parser = sp.getXMLReader();
              //NO Validation done on for this because we do NOT have a DTD.
              sax2parser.setFeature(
                   "http://xml.org/sax/features/validation",
                   false);
              sax2parser.setContentHandler(new FileContentHandler());
              //we create a character array of the length of the xml message String
              char[] messageCharacterArray =
                   new char[xmlString.length()];
              // we then put the xml string into the character array.
              messageCharacterArray = xmlString.toCharArray();
              // after this ew end up creating a CharArrayReader that will be used by the Sax
              // parser to parse the xml.
              CharArrayReader xmlCharArrayReader =
                   new CharArrayReader(messageCharacterArray);
              // we put the xml character array within the Input Source which will then be parsed
              // by the Sax2 parser.
              InputSource in = new InputSource(xmlCharArrayReader);
              // Use a Transformer for outputting the message into our formatted xml using
              // the stylesheet defined up in a messages own sxl stylesheet file.
              TransformerFactory tFactory = TransformerFactory.newInstance();
              tFactory.setURIResolver(new BasicURIResolver());
              StreamSource stylesource = new StreamSource(styleSheetInputStream);
              Transformer transformer = tFactory.newTransformer(stylesource);
    //          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    //          transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    //          Properties properties = new Properties();
    //          properties.setProperty("indent", "yes");
    //          properties.setProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    //          transformer.setOutputProperties(properties);
              // We will use a ByteArrayOutputStream to put our transformed xml.
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              StreamResult result = new StreamResult(bos);
              SAXSource source = new SAXSource(in);
              transformer.transform(source, result);
              String s = bos.toString();
              StringBuffer sb = new StringBuffer();
              //This will make sure the Version Line is not shown.
              BufferedReader br = new BufferedReader(new StringReader(s));
              String line = "";
              while ((line = br.readLine()) != null) {
                        sb.append(line);
              bos.close();
              br.close();
              formattedXmlString = sb.toString();
              System.out.println("--------------------------------");
              System.out.println(formattedXmlString);
              System.out.println("--------------------------------");
              } catch (Exception e) {
                   e.printStackTrace();
    I have been searching and trying to figure this out forever. Any help would be greatly appreciated. Bottom line is that I want carriage returns and tabs to work when transferring from the xml to xsl.

    I get the following line when adding the <pre> tags.
    /* Ensure that player name exist in the system*/if (player =null)     NullPlayerException;          if (NOT (isPlayerNameExist(player)))               throw PlayerNameNotExistException;          /* Ensure player name exist in the team already*/          i ? 1;          while (i <= length(mPlayers)) {               if (mPlayers[i].mPlayerName != playerName)                    throw PlayerNameNotExistInTeamException;}this.mPlayers ? this.mPlayers - player;
    On the screen this is shown on 1 line. It looks like the tabs are working correctly. However, the carriage return, line feeds do not seem to be working. The xml that is pushed into the transformation has the carriage returns and line feeds and is formatted correctly. There has to be something happening when the xsl takes the xml String. When I add <BR></BR> within the xml that doesn't seem to work either.
    I am really sumpted. If you could help DrClap I would really be appreciated.

  • How to display XML file that XI sent to my j2ee appl?

    Hi,
    In my scenario File->XI->J2EE appl.
    I got XML page cannot be displayed.
    XML document must have a top level element. Error processing resource 'http://localhost:7001/Invoke/DisplayRes'.
    I deployed my .ear file on BEA Weblogic application server9.0
    I found no error when i tested in SXI_MONI and RWB->Message monitor as well.
    This is my servlet code:
    public class DisplayRes extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         doPost(request,response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         BufferedReader brin =new BufferedReader(new InputStreamReader(request.getInputStream()));
         String inputLine;
         StringBuffer sBuf = new StringBuffer();
         PrintWriter out = response.getWriter();
         response.setContentType("text/xml");
         while ((inputLine = brin.readLine()) != null)
             sBuf.append(inputLine);       
             //out.setContentType("text/xml");
             //out.println(sBuf.toString());
             out.write(sBuf.toString());
              brin.close();
             out.flush();
    What went wrong.All helpful answers are highly rewarded.
    Thanks

    Hi
    Can anyone tell me how XI sends messages to applications like J2EE. In REceiver comm channel, I think we specify about the target system like J2EE appl.
    Aadapter Type: HTTP
                   Receiver
    Transport Protocol:  HTTP1.0
    Message Protocol:    XI payload in HTTP body
    Adapter Engine:      Integration Server
    Addressing Type:     URL address
    Target host:         localhost
    Service Number:      7001(Port number of Weblogic appl server--where my J2EE appl is deployed).
    Path     :  /Invoke/DisplayRes/
    Authentication Type:Use Logon Data for SAP System
    Content Type: text/xml
    Username:   xiappluser
    password:   xx
    XML code:   UTF-8
    I suppose XI sends msgs to http://localhost:7001/Invoke/DisplayRes/........
    in this example if am correct?
    Then I have given all tyhe necessary setting but my servlet is not able to display XML msg in browser?
    This is my servlet code:
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         PrintWriter out = response.getWriter();
         BufferedReader brin =new BufferedReader(new InputStreamReader(request.getInputStream()));
         String inputLine;
         StringBuffer sBuf = new StringBuffer();
            response.setContentType("text/xml");
         while ((inputLine = brin.readLine()) != null)
             sBuf.append(inputLine);
             out.println("hi");            
                out.println(sBuf.toString());
             brin.close();
             out.flush();
    What went wrong?
    Help me, all helpful answers are highly rewarded.
    Thanks

  • How to escape or remove the special characters in the xml element by regula

    Hi members,
    How to escape or remove the special characters in the xml element by regular expression  in java??
    For Example ,
    <my:name> aaaa </my:name>
    <my:age> 27 </my:age>
    In the above example , i have to retrieve the value of the <my:name> Element(For examlpe -- i have to get "aaaa" from <my:name> tag)...
    How to retreive this value by using DOM with XPATH in java
    Thanks in Advance

    Hi members,
    I forget to paste my coding for the above question....This is my coding......In this display the error...... Pls reply ASAP.......
    PROGRAM:
    import java.io.IOException;
    import java.util.Hashtable;
    import java.util.Map;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;
    import javax.xml.parsers.*;
    import javax.xml.xpath.*;
    public class DOMReaderForXMP {
         static Document doc;
         static XPath xpath;
         static Object result;
         static NodeList nodes;
         public DOMReaderForXMP() throws ParserConfigurationException, SAXException,
                   IOException, XPathExpressionException {
              DocumentBuilderFactory domFactory = DocumentBuilderFactory
                        .newInstance();
              domFactory.setNamespaceAware(true);
              DocumentBuilder builder = domFactory.newDocumentBuilder();
              doc = builder.parse("d:\\XMP.xml");
              XPathFactory factory = XPathFactory.newInstance();
              xpath = factory.newXPath();
         public static void perform(String path) throws Exception {
              result = xpath.evaluate(path, doc, XPathConstants.NODESET);
              nodes = (NodeList) result;
         public void check() throws Exception {
              perform("//my:name/text()");
              if (!nodes.item(0).getNodeValue().equals("application/pdf")) {
                   System.out.println("Mathces....!");
    ERROR:
    Exception in thread "main" net.sf.saxon.trans.StaticError: XPath syntax error at char 9 in {/my:name}:
    Prefix aas has not been declared

  • How to map more than one xml element with some Paragraph in a Text Frame

    Hi friends,
    I am new in InDesign Java Scripting and I have to place or map, more than one xml elements of different parents, into one textbox. Is it possible through JavaScript? Can anyone help me in this because I have no idea how it should work and it urgently required.
    Thanks in Advance

    I had answered to you already in your first post: the short answer is that it's not possible on the same text box unless you assign a common ancestor of these two "parents" item. That's not a question of scripting, it's the way Indesign handle the XML with the layout. Import a xml in Indesign and drop tags to page item. What you can do manually is quite representative of what can be done through scripting.
    If you assign this anscestor to the text frame, you have to expect that all text child items will be displayed in the text frame (including the text of all the child of the two "parents" and all the other parents/childs that could be under the common ancestor). Having a XML that is designed for Indesign usage is pretty much inevitable if you are doing anything "serious".

  • Safari won't display XML content with an embedded stylesheet

    I'm using Safari 5.0.2 on Windows XP. I cannot get it to display an XML document with an embedded CSS stylesheet. The file in question appears in this ZIP file: http://www.hl7.org/documentcenter/ballots/2011JAN/downloads/CDAR2IG_SDISP_R1_D12011JAN.zip
    That document demonstrates is an attempt to enable display of standardized healthcare content in common web browsers. Can anyone here help?

    I have a separate bug report to Chrome on this one, same general result in display. The file is an XML document, not a CSS style-sheet. It contains an xml-stylesheet processing instruction that has a local URI #hl7-css-for-cda pointing to an element in the XML that contains the CSS stylesheet. That element uses xml:id to identify itself, so it is (according to the W3C) possible for the browser to determine that element as being the target of the URI.
    The problem appears to be that the Display Engine in Safari won't load the content of that URI as a CSS stylesheet.
    When I validate the CSS content in that XML element it returns as being valid CSS, and when I validate the XML using my XML editor, it is both well formed, and valid against the XML Schema appropriate to that file.

  • XML Element of XML Element of XML Element (and so on...)

    Here is my XML data (shorted, in a file myFile):
    <LiveData>
    <Voltage>
    <Total>
    <VoltageNow>1052</VoltageNow>
    </Total>
    </Voltage>
    <Power>
    <Total>
    <PowerNow>345</PowerNow>
    </Total>
    </LiveData>
    I would like to get the VoltageNow and PowerNow values, but the following script does not work:
    tell application "System Events"
    set elem1 to XML element 1 of XML file myFile /*<LiveData>
    set power to XML elements of elem1 whose name is "Power"
    set total to XML elements of power whose name is "Total"
    set powernow to value of XML elements of total whose name is "PowerNow"
    end tell
    Error: System Events got an error: Can’t make {} into type string.
    BTW, I don't want to use XML Element X because the order may change.
    What is the correct method to traverse these elements to obtain values?

    AppleScript can handle the strings, but the System Events XML Suite doesn't work with text strings - it deals with the XML objects, which have name and value properties. The handler can be modified to show the names of an element, but it is just designed to work with the XML Suite.
    The contents of an XML file is just text, so you can forgo System Events and just use regular text manipulation statements, or use another tool such as the Satimage XMLLib osax, which is much more robust and does include commands to display the XML object as a string.
    By the way, my original handler was designed and tested in Leopard, but I discovered a Snow Leopard bug that alters the way it returns array/list contents. The following script has changes that return the functionality, in addition to a dialog handler that will display lists:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #DAFFB6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    on run -- example
    set XMLFile to (choose file without invisibles)
    show("element value:", (getXMLElement from {XMLFile, "LiveData", "Voltage", "Total", "VoltageNow"}))
    end run
    to show(label, something)
    show an alert for something, formatting lists and records
    parameters - label [text]: the alert text
    something [mixed]: an item to put in the alert message
    returns nothing
    if something is not in {null, missing value} then
    try -- show the message
    if (class of something) is in {list, record} then (something as number) -- force an error
    display alert label message (something as text)
    on error errorMessage -- lists and records don't format very well, so cheat
    set {here, there} to {(offset of "{" in errorMessage), -(offset of "}" in (reverse of text items of errorMessage) as text)}
    display alert label message text here thru there of errorMessage
    end try
    else
    display alert label message "*null or missing value*"
    end if
    end show
    to getXMLElement from XMLItems
    get the specified element from a simple XML structure by name or index
        the number of items is not fixed, but must be at least 2 (the XML file and an XML element)
      parameters: XMLItems [list] -
    item 1 [text]: the XML file path (Finder or POSIX)
    item 2 [mixed]: the XML element name or index (names are case sensitive)
    item(s) 3+ [mixed]: sub item(s)
    returns [list]: value of the element
    try
    if (count XMLItems) is less than 2 then error "getXMLElement handler:  item list contains too few items"
    tell application "System Events"
    set theXMLData to contents of XML file ((the first item of XMLItems) as text)
    -- get text of theXMLData
    set theXMLElement to XML element 1 of theXMLData -- start at the root element
    repeat with anItem in rest of XMLItems -- add on the sub items
    set anItem to contents of anItem
    try
    set anItem to anItem as integer -- index number?
    end try
    set theXMLElement to (get XML element anItem of theXMLElement)
    end repeat
    try -- return the element(s)
    -- return name of XML elements of theXMLElement
    set theResult to value of theXMLElement -- SL built-in result variable does not get set
    if theResult is missing value then error -- SL does not error on empty or missing value
    return theResult
    on error errorMessage number errorNumber -- the element is empty, or a list of items
    log errorMessage
    return value of XML elements of theXMLElement
    end try
    end tell
    on error errorMessage number errorNumber
    log errorMessage
    -- return null
    error "getXMLElement handler:  element not found (" & errorNumber & ")"
    end try
    end getXMLElement</pre>

  • XML element,if not including any attributes and/or child elements then

    XML element in SQLX,if not including any attributes and/or child elements then the tag should not appear, how to achive this?
    ex:Consider for <enumeration> tag where it is having some value.
    <attribute>
    <name>Ethernet Access</name>
    <enumeration>
    <StringValue>Bandwidth</StringValue>
    </enumeration>
    </attribute>
    When <enumeration> tag is not have any Value in this, then output should be as follows.
    <attribute>
    <name>Ethernet Access</name>
    </attribute>
    But what i am getting is
    <attribute>
    <name>Ethernet Access</name>
    </enumeration>
    </attribute>
    Please suggest me the solution for this.
    I tried , but when xmlelement() is not having data it will display empty tag ie </enumeration>, If xmlforest() are null it wont show tag, But i have to use xmlelement only. how can that be achived using xmlelement .

    Use a SQL case - when - else end construct to only execute the xmlelement if data is present. The SQL/XML standard is very clear, xmlElement will generate an empty element if no data is present. xmlforest will not.

  • How to refer ?XML element tag name? in the RTF variable

    Hi All,
    I want to declare variable and assign the value of XML element tag to that variable.
    Following are the steps:
    <?xdoxslt:set_variable($_XDOCTX, MYCOUNT,1)?>
    <?xdoxslt:get_variable($_XDOCTX, MYCOUNT)?>
    <?if: xdoxslt:get_variable($_XDOCTX, MYCOUNT) =1?>xxx<?end if?>
    In the declaration part,I need to replace 1 with some of the xml element tag value(for example : <?vendor_name?>).
    But when I try to do so,I get some list of exceptions.
    Please suggest how to proceed.
    Thanks and Regards,
    Kaveri

    Hi Pradeep,
    Thanks for your response.Here my requirement goes:
    for -each:
    text(database value)
    end for-each
    This text value will continue from page 1 to N.
    So for page1 I want HEADER1 and from page2 onwards,I require different header HEADR2.
    By using your approach,my text which needs to be continued on different pages will not be acheived.
    One more thing I got from XMLP User guide:
    <xdofo:inline-total
    display-condition="exceptfirst"
    name="InvAmt">.
    SInce all my tags are generated from Oracel reports,I am unable to use the above xml line.Is there any way to use this by modifying the syntax..
    Please let me know your suggestions since this is show stopper for my report.
    Thanks and Regards,
    Kaveri

  • Dealing with optional XML elements

    We have a template that will print certain tables based on whether or not an element is present in the incoming XML file.
    I have no problem displaying these tables conditionally on XML elements that are always present (i.e. I can say <?if:element='Y'?>) but I'm running into problems when I need to display a table/field based on whether or not an element is present.
    Also, when the element in question is not present, the template ignores my page break and prints the remainder of the document on the same page.
    Can anyone recommend a way to accomplish the above?
    Thanks.

    You should use <?if:element = ''?> or <?if:element != ''?>
    This should work also:
    <?if:text(element)?> or <?if:not(text(element))?>
    The condition is always true (false) when either the element is empty or does not
    exist. Let me know, if you need to differentiate between both (probably using name() instead of text will work in this case).
    If a pagebreak is inside the if statement than it is only shown when the condition is satisfied.
    Hope that helps,
    Klaus

  • Displaying XML Namespaces in JTextArea

    Hi,
    I want to add the Namespaces to a XML element in the below given way,
    Please tell me how to do it....
    <process name="meritprocess"
    xmlns:lns="http://www.w3.org/TR/wsdl"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="BpelSchema.xsd">
    thanks....

    How is it giving you trouble? There does not appear to be any JTextArea in the code you posted. Hint: use the code /code tags to make your code readable.
    Just guessing: Change your System.out.println commands so that all of the output gets put into a single String, and return that String. Example:
    String result = "Details for occupied rooms by name are: ";
    for(int j = 0; j < aCount; j++)
    result = result + "Customer name: " +rm[j].getCustomerName()
    +" Room No." + rm[j].getRoomNumber()+ " Payee:"
    + rm[j].getPayeeName();
    return result;Then use setText() method of JTextArea to display the String.

  • Display xml- tags with NULL - value

    Hello
    is there a way to display a tag while the value is null in this matter :
    select
    xmlforest(AFRAGNR_1, AFRAGNR_2 , AFRAGNR_3 ,AFRAGNR_4 )
    AS XML
    FROM VIEW_ABC WHERE x = v1 and y = v2
    -- result: :AFRAGNR_3 and AFRAGNR_4 is null and not displayed:
    XML
    &lt;AFRAGNR_1&gt;J&lt;/AFRAGNR_1&gt;&lt;AFRAGNR_2&gt;J&lt;/AFRAGNR_2&gt;
    -- by using this, its not the result I want to get,
    select
    xmlelement( "AFRAGNR_1" , AFRAGNR_1 ) AFRAGNR_1
    ,xmlelement( "AFRAGNR_2" , AFRAGNR_2 ) AFRAGNR_2
    ,xmlelement( "AFRAGNR_3" , AFRAGNR_3 ) AFRAGNR_3
    ,xmlelement( "AFRAGNR_4" , AFRAGNR_4 ) AFRAGNR_4
    FROM VIEW_ABC WHERE x = v1 and y = v2
    another way ?
    regards Norbert
    Edited by: astramare on Nov 20, 2008 12:32 PM

    I have the same problem:
    - I need to generate XML in format <element id="1" />
    - I need to pass some null values:
    SELECT XMLElement ( "ShipToAddress"
    , XMLAttributes ( customer_id as "CustomerNo"
    , '' as "Code"
    , substr(name,1,30) as "Name"
    , '' as "Name2"
    , substr(street||' '||house_nr,1,30) as "Address"
    , '' as "Address2"
    , city as "City"
    , last_name ||' '|| first_name as "Contact"
    , phone as "PhoneNo"
    , '' as "CountryCode"
    , fax as "FaxNo"
    , zip_cd||' '||postal_code_extention as "PostCode"
    , '' as "County"
    , email as "EMail"
    , website as "HomePage")) customer
    FROM customers;
    result should be:
    <ShipToAddress CustomerNo="100001004" Code="3" Name="4C
    Cons" Name2="" Address="Metrologielaan" Address2="" City="BRUSSEL" Contact="" PhoneNo="" CountryCode="BE" FaxNo="" PostCode="1130" County="" EMail="" HomePage="" />
    and NOT (this is my result at the moment):
    <ShipToAddress CustomerNo="100001004" Code="3" Name="4C
    Cons" Address="Metrologielaan" City="BRUSSEL" CountryCode="BE" PostCode="1130"></ShipToAddress>;
    Can someone help me with this please?
    Edited by: willeha on Mar 5, 2009 7:18 AM

Maybe you are looking for

  • Populate & Retrieve in one Select - problems !!!

    Hi There. What I would like to be able to do is populate a row in a table (via a function) and retrieve that row all in one Select statement. Unfortunately I don't get any data returned from the Select. I have in mind something like the following:- S

  • My blackberry app world wont work!:S

    i put the rigth email and password in and click login and it says 'authenticating..... t'hen says 'an error gass occurred. please try again later.' it has been like this for  2 weeks now! what should i do thank xoxo

  • Forms 6i and Reports 10g

    Hello together, You can see at the subject that I want to combine Forms 6i and Reports 10g. Why? 6i does not support html interpretation and unicode. So what do you think about the kombination with old (Forms) 6i and new 10g (Reports)? How does the R

  • XSTL-JAVA error Illegal number of arguments or types of arguments in a call

    Hi All, I get this error when invoking my Java function from XSLT.I am passing Strings with global param defined like this . <xsl:param name="inputparam"/> <xsl:param name="gid" select="//GENERAL_ID"/> <xsl:param name="vtype" select="//VESSEL"/> <xsl

  • I am stuck on the wrong resolution and have tried everything. Please help.

    My Mac Mini is stuck on the wrong resolution, and I have tried resetting my Mac's PRAM, I tried booting into safe mode, and I tried resetting the SMC, but none fixed the problem.