SAX, incor. data for XML element, XML 1.1 doc (1.0 ok) in JRE 6 (JRE 5 ok)

Hello,
for some reason, the test case below fails when driven with Java 6. Looks like, when long string data is stored in a XML element, DocumentHandler's characters() method will be provided with incorrect data.
With XML 1.0, parsing works fine in all my tests, Apache Xerces, JRE 5, JRE 6.
With XML 1.1., parsing works fine with Apache Xerces, JRE5 but not with JRE6.
I've checked it with latest JRE 6 update 4.
Anyone else xperiencing such problems with XML1.1 parsing when using JAXP bundled with Java 6?
I've tried to file a bug at bugdatabase, but for some reason I got no response for my issue - so I'm trying the forum now ;-)
Thanx for comments
Merten
import java.io.StringReader;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import junit.framework.TestCase;
import junit.framework.TestResult;
import junit.framework.TestSuite;
/** snippet to demonstrate problem in SAXParser */
public class ProblemWithSAXParser extends TestCase
public static void main(String[] args)
TestResult result=junit.textui.TestRunner.run(suite());
System.exit(result.wasSuccessful() ? 0 : 1);
private static junit.framework.Test suite()
final TestSuite ts=new TestSuite();
ts.addTestSuite(ProblemWithSAXParser.class);
return (ts);
/** small DocumentHandler, just waiting for one and only XML element <c></c> */
class MySAXDocumentHandler extends DefaultHandler
boolean listening=false;
public void startElement(final String uri, final String localName, final String qName, final Attributes attributes)
throws SAXException
System.out.println("startElement uri " + uri + " localName " + localName + " qName " + qName);
if("c".equals(qName))
listening=true;
public void endElement(final String uri, final String localName, final String qName) throws SAXException
System.out.println("endElement uri " + uri + " localName " + localName + " qName " + qName);
if("c".equals(qName))
listening=false;
public void characters(final char ch[], final int start, final int length) throws SAXException
if(listening)
final String str=new String(ch, start, length);
System.out.println("<c> element, start==" + start + " length==" + length + " ch.length==" + ch.length + " ch=="
+ str);
sb.append(str);
private final StringBuffer sb=new StringBuffer();
/** return what I got for XML element <c></c> */
public String toString()
return (sb.toString());
/** test an XML document with an element <c>, use XML 1.0 and XML 1.1 and some (more)
* content in the XML element */
public void testWithSunAndApache() throws Exception
// test XML element content for <c> element
final StringBuffer plain_str=new StringBuffer("");
for(int i=0; i < 500; i++)
plain_str.append("0123456789 This is some text ").append(i).append(". ");
final String xml_orig=plain_str.toString();
// SAX parsers, one Sun, one (original) Apache Xerces
// accept that Apache Xerces is not in path ...
final String prop_name="javax.xml.parsers.SAXParserFactory";
final String prop_val_sun="com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";
final String prop_val_apache="org.apache.xerces.jaxp.SAXParserFactoryImpl";
System.setProperty(prop_name, prop_val_sun);
final SAXParser sax_sun=SAXParserFactory.newInstance().newSAXParser();
System.out.println("SaxParser Sun= " + sax_sun);
assertTrue(("" + sax_sun).indexOf("com.sun.") >= 0);
System.setProperty(prop_name, prop_val_apache);
SAXParser sax_apache;
try
sax_apache=SAXParserFactory.newInstance().newSAXParser();
catch(final Throwable t)
System.err.println("no Apache Xerces in path? " + t);
sax_apache=null;
System.out.println("SaxParser Apache= " + sax_apache);
assertTrue(sax_apache==null || ("" + sax_apache).startsWith("org.apache."));
// i==0: XML 1.0, i==1: XML 1.1
for(int i=0; i <= 1; i++)
assert i == 0 || i == 1;
final String xml_version=(i == 0 ? "1.0" : "1.1");
final StringBuffer sb=new StringBuffer("<?xml version=\"" + xml_version + "\" encoding=\"UTF-8\"?><c>");
sb.append(xml_orig);
sb.append("</c>");
final String xml=sb.toString();
// parse it!
final StringReader string_reader_sun, string_reader_apache;
string_reader_sun=new StringReader(xml);
final InputSource input_source_sun=new InputSource(string_reader_sun);
string_reader_apache=new StringReader(xml);
final InputSource input_source_apache=new InputSource(string_reader_apache);
final MySAXDocumentHandler my_handler_sun, my_handler_apache;
my_handler_sun=new MySAXDocumentHandler();
my_handler_apache=new MySAXDocumentHandler();
sax_sun.parse(input_source_sun, my_handler_sun);
if(sax_apache!=null)
sax_apache.parse(input_source_apache, my_handler_apache);
final String xml_sun=my_handler_sun.toString();
final String xml_apache=my_handler_apache.toString();
assertNotNull(xml_sun);
assertNotNull(xml_apache);
System.out.println("xml version " + xml_version);
System.out.println("xml " + xml);
System.out.println("xml_orig " + xml_orig);
System.out.println("xml_sun " + xml_sun);
System.out.println("xml_apache " + xml_apache);
// test the data returned from DocumentHandler
if(sax_apache!=null)
assertEquals(xml_orig, xml_apache);
assertEquals(xml_orig.length(), xml_sun.length()); // length seems to be okay
assertEquals(xml_orig, xml_sun); // content seems to be not okay for XML 1.1
}

thanx, DrClap, haven't seen the "code" button for some reason, code is attached again
The output of my test is like this for JRE6 (truncated)
xml_sun 456789 This is is some text 0. 0123456789 This is some text 1.
xml_apache 0123456789 This is some text 0. 0123456789 This is some text 1.
Notice, xml_sun not only starts wrong ("0123" missing) - for some reason, the text there is not "This is some text" but "This is is some text" - very interesting in a way. I guess there's an issue with repeated text chunks ...
So, the data in my XML element is kind of changed, the length of the string is okay but the characters are "misplaced" or so :-) I thought about a problem with StringBuffer first, but the StringBuffer works fine for Apache ... so I really think there's an issue with JRE 6's parser for XML 1.1
Merten
import java.io.StringReader;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import junit.framework.TestCase;
import junit.framework.TestResult;
import junit.framework.TestSuite;
/** snippet to demonstrate problem in SAXParser */
public class ProblemWithSAXParser extends TestCase
public static void main(String[] args)
  TestResult result=junit.textui.TestRunner.run(suite());
  System.exit(result.wasSuccessful() ? 0 : 1);
private static junit.framework.Test suite()
  final TestSuite ts=new TestSuite();
  ts.addTestSuite(ProblemWithSAXParser.class);
  return (ts);
/** small DocumentHandler, just waiting for one and only XML element <c></c> */
class MySAXDocumentHandler extends DefaultHandler
  boolean listening=false;
  public void startElement(final String uri, final String localName, final String qName, final Attributes attributes)
    throws SAXException
   System.out.println("startElement uri " + uri + " localName " + localName + " qName " + qName);
   if("c".equals(qName))
    listening=true;
  public void endElement(final String uri, final String localName, final String qName) throws SAXException
   System.out.println("endElement uri " + uri + " localName " + localName + " qName " + qName);
   if("c".equals(qName))
    listening=false;
  public void characters(final char ch[], final int start, final int length) throws SAXException
   if(listening)
    final String str=new String(ch, start, length);
    System.out.println("<c> element, start==" + start + " length==" + length + " ch.length==" + ch.length + " ch=="
      + str);
    sb.append(str);
  private final StringBuffer sb=new StringBuffer();
  /** return what I got for XML element <c></c> */
  public String toString()
   return (sb.toString());
/** test an XML document with an element <c>, use XML 1.0 and XML 1.1 and some (more)
  * content in the XML element */
public void testWithSunAndApache() throws Exception
  // test XML element content for <c> element
  final StringBuffer plain_str=new StringBuffer("");
  for(int i=0; i < 500; i++)
   plain_str.append("0123456789 This is some text ").append(i).append(". ");
  final String xml_orig=plain_str.toString();
  // SAX parsers, one Sun, one (original) Apache Xerces
  // accept that Apache Xerces is not in path ...
  final String prop_name="javax.xml.parsers.SAXParserFactory";
  final String prop_val_sun="com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";
  final String prop_val_apache="org.apache.xerces.jaxp.SAXParserFactoryImpl";
  System.setProperty(prop_name, prop_val_sun);
  final SAXParser sax_sun=SAXParserFactory.newInstance().newSAXParser();
  System.out.println("SaxParser Sun= " + sax_sun);
  assertTrue(("" + sax_sun).indexOf("com.sun.") >= 0);
  System.setProperty(prop_name, prop_val_apache);
  SAXParser sax_apache;
  try
   sax_apache=SAXParserFactory.newInstance().newSAXParser();
  catch(final Throwable t)
   System.err.println("no Apache Xerces in path? " + t);
   sax_apache=null;
  System.out.println("SaxParser Apache= " + sax_apache);
  assertTrue(sax_apache==null || ("" + sax_apache).startsWith("org.apache."));
  // i==0: XML 1.0, i==1: XML 1.1
  for(int i=0; i <= 1; i++)
   assert i == 0 || i == 1;
   final String xml_version=(i == 0 ? "1.0" : "1.1");
   final StringBuffer sb=new StringBuffer("<?xml version=\"" + xml_version + "\" encoding=\"UTF-8\"?><c>");
   sb.append(xml_orig);
   sb.append("</c>");
   final String xml=sb.toString();
   // parse it!
   final StringReader string_reader_sun, string_reader_apache;
   string_reader_sun=new StringReader(xml);
   final InputSource input_source_sun=new InputSource(string_reader_sun);
   string_reader_apache=new StringReader(xml);
   final InputSource input_source_apache=new InputSource(string_reader_apache);
   final MySAXDocumentHandler my_handler_sun, my_handler_apache;
   my_handler_sun=new MySAXDocumentHandler();
   my_handler_apache=new MySAXDocumentHandler();
   sax_sun.parse(input_source_sun, my_handler_sun);
   if(sax_apache!=null)
    sax_apache.parse(input_source_apache, my_handler_apache);
   final String xml_sun=my_handler_sun.toString();
   final String xml_apache=my_handler_apache.toString();
   assertNotNull(xml_sun);
   assertNotNull(xml_apache);
   System.out.println("xml version " + xml_version);
   System.out.println("xml        " + xml);
   System.out.println("xml_orig   " + xml_orig);
   System.out.println("xml_sun    " + xml_sun);
   System.out.println("xml_apache " + xml_apache);
   // test the data returned from DocumentHandler
   if(sax_apache!=null)
    assertEquals(xml_orig, xml_apache);
   assertEquals(xml_orig.length(), xml_sun.length()); // length seems to be okay
   assertEquals(xml_orig, xml_sun); // content seems to be not okay for XML 1.1
}

Similar Messages

  • How to check the data for duplicates in xml

    Hi all,
    I have an xml similar to the below. In that I need an xquery which can remove the tags for which the data is same. For example in the below xml for first <customer> first <address> the <houseno>
    and the second <address>'s <houseno> is same in that case there should be only one <houseno> tag with the data in the output xml. Please check the Input XML and Output XML xml formats below .
    I am able to get the OUtputxml but with the same <houseno> repeating. I am not able to find a way in which I can chk the data and stop the tag getting created in the output.
    Could you please suggest me the ways in which I can do. It would be of great help for me. Thanks a ton in advance.
    Input XML
    <customers>
         <customer>
              <address>
                   <houseno>212</houseno>
                    <phone>121221</phone>
              </address>
              <address>
                   <houseno>212</houseno>
                   <phone>42334</phone>             
              </address>
         <customer>
         <customer>
              <address>
                   <houseno>3243</houseno>
                   <phone>6565</phone>
              </address>
              <address>
                   <houseno>3434</houseno>
                    <phone>78778</phone>
              </address>
         </customer>
    </customers>
    Output XML Expected
    <customers>
    <customer>
              <address>
                   <houseno>212</houseno>
                    <phone>121221</phone>
                      <phone>42334</phone>              
              </address>
         <customer>
    <customer>
              <address>
                   <houseno>3243</houseno>
                   <phone>6565</phone>
                   <houseno>3434</houseno>
                    <phone>78778</phone>
              </address>
         </customer>
    </customers>
    Output XML Which I am getting
    <customers>
    <customer>
              <address>
                   <houseno>212</houseno>
                    <houseno>212</houseno>        
                    <phone>121221</phone>
                      <phone>42334</phone>              
              </address>
         <customer>
    <customer>
              <address>
                   <houseno>3243</houseno>
                   <phone>6565</phone>
                   <houseno>3434</houseno>
                    <phone>6565</phone>
              </address>
         </customer>
    </customers>
    Regards

    First of all the desired output.
    [quote]
    <customers>
    <customer>
              <address>
                   <houseno>212</houseno>
                    <phone>121221</phone>
                      <phone>42334</phone>              
              </address>
         <customer>
    <customer>
              <address>
                   <houseno>3243</houseno>
                   <phone>6565</phone>
                   <houseno>3434</houseno>
                    <phone>78778</phone>
              </address>
         </customer>
    </customers>
    [/quote]
    I don't think this is a very good choice and will be causing trouble no end in a future stage of using the data...
    I would rather propose a better choice to my thinking like this.
    [code]
    <customers>
        <customer>
              <address>
                   <house houseno="212">
                       <phone>121221</phone>
                       <phone>42334</phone>
                   </house>
              </address>
         </customer>
        <customer>
            <address>
                <house houseno="3243">
                    <phone>6565</phone>
                </house>
                <house houseno="3434">
                    <phone>78778</phone>
                </house>
           </address>
      </customer></customers>
    [/code]
    In that case, this is capable of producing the regrouped output.
    [code]
    <customers>{
        let $doc:=doc("your_data.xml")
        for $customer in $doc/customers/customer
        return
        <customer>{
            for $houseno in distinct-values($customer/address/houseno)
            return
            <house houseno="{$houseno}">{
               for $phone in $customer/address[houseno=$houseno]/phone
               return
               <phone>{data($phone)}</phone>
            }</house>
        }</customer>
    }</customers>
    [/code]

  • Actual Finish Date for WBS Elements

    Hi,
      We are not using the functionality of network of PS in our orgnisation.  We would like to put a actual finish date for the WBS element so that further GRN entries can be restricted.  Appreciate if someone can guide on this.
    Regards,
    Anand

    By maintaining Actual finish date in WBS wil not restric the GR.
    In the Status profile create a User Status (Ex:COMP) and set "Goods receipt for prodn. order" and "Goods receipt for purch. order" as forbidden. Then set this user staus for the WBS once actual date is achieved.

  • XSLT and XML - Splitting out address data for a single XML item?

    Hi,
    I am currently having to change my XSLT code for processing XML feeds from the NHS because the technolgy has been moved from SOAP-based to RESTful (both of which mean very little to me!).  While most of the XML feeds display correctly I have been unable to resolve the following:
    The address data seems to be located under a single item <s.addressLine> rather than <address1>, <address2> <address3> <address4> as in the previous setup.  As a consequence of this I am unable to split out my address data into seperate address fields (in column 2 below).  The code below ....
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:s="http://syndication.nhschoices.nhs.uk/services">
    <xsl:output method="html" encoding="UTF-8"/>
    <xsl:template match="/">
    <table class="xslt_table">
      <tr>
        <th>1</th>
        <th>2</th>
        <th>3</th>
      </tr>
      <xsl:for-each select="atom:feed/atom:entry">
        <tr>
          <td><xsl:value-of select="atom:content/s:organisationSummary/s:name"/></td>
          <td><xsl:value-of select="atom:content/s:organisationSummary/s:address"/></td>
          <td><xsl:value-of select="atom:content/s:organisationSummary/s:address/s:addressLine"/></td>
        </tr>
      </xsl:for-each>
    </table>
    </xsl:template>
    </xsl:stylesheet>
    ....generates the following result:
    1
    2
    3
    Royal Eye Infirmary
    Apsley RoadPlymouthDevonPL4 6PL
    Apsley Road
    Mount Gould Hospital
    Mount Gould RoadPlymouthDevonPL4 7QD
    Mount Gould Road
    Scott Hospital
    Beacon Park RoadPlymouthDevonPL2 2PQ
    Beacon Park Road
    Peninsula NHS Treatment Centre
    20 Brest RoadPlymouthDevonPL6 5XP
    20 Brest Road
    Derriford Hospital
    Derriford RoadCrownhillPlymouthDevonPL6 8DH
    Derriford Road
    Nuffield Health, Plymouth Hospital
    Derriford RoadPlymouthDevonPL6 8BG
    Derriford Road
    Plympton Hospital
    Market RoadPlymouthDevonPL7 1QR
    Market Road
    St Barnabas Hospital
    Higher Port ViewSaltashCornwallPL12 4BU
    Higher Port View
    Liskeard Community Hospital
    Clemo RoadLiskeardCornwallPL14 3XD
    Clemo Road
    I would be very, very grateful for any thoughts and suggestions on what I might be able to do to resolve this.
    Best wishes
    Simon

    Thanks dvohra
    But in my servlet, I already have the transformer factory defined as follows
    public class JDOMServlet extends HttpServlet {
         private TransformerFactory tFactory = TransformerFactory.newInstance();
         private ResultSet rs = null;
         private StreamSource xsltSource;
         private Templates template;
         public void init(ServletConfig config) throws ServletException {
              super.init(config);
              ServletContext ctx = config.getServletContext();
              try {
                   //Want to cache the stylesheet for future resuse
                   //then it doesnt have to be loaded constantly
                   URL xslURL = ctx.getResource("/WEB-INF/viewStudentDetails.xsl");
                   System.out.println(xslURL);
                   xsltSource = new StreamSource(new java.net.URL(xslURL.toString()).openStream());
                   //xsltSource = new StreamSource(ctx.getResourceAsStream("/Web-inf/viewStudentDetails.xsl"));
                   template = tFactory.newTemplates(xsltSource);
              catch (Exception e) {
                   e.printStackTrace();
    I think the key point is that, this transformation servlet worked fine, when all it was outputting was the xml data, styled in a table. As soon as I enter more table info, (i.e. for the banner and navigation bar), the null pointer exception pops up.
    ....a lost and puzzled jase....
    Thanks again.
    JS

  • Change date for cost element

    hi
         i created the cost element vaild from 01.04.2008 instent of 01.04.2007 then i saved. now i want change the date i.e valid from 01.04.2007,. i don't want delete the cost element in ka05 then create,
    i want change the validty with out deleting the cost element.

    Please read the post. WIth the suggestion you have given teh system will allow to change the period to a future date and not to the past date.
    In this case the hasc reated a cost element with effective from 2008 where as he wants to change this to 2007.
    system will not allow this.
    "You selected an analysis period extending beyond the period for which the object was defined. This is not allowed in the change or display functions."

  • OTL - data for Dummy Element Context wrong entry in HXC_TIME_ATTRIBUTES

    Hi,
    I have create a Choice_List in the timecard using one of the seeded Custom view objects. In the LDT file, I specified QUALIFIER_ATTRIBUTE26 = 'Dummy Element Context'.
    It's showing up correctly, but when I save the created timecard,
    the value is being saved in HXC_TIME_ATTRIBUTES with ATTRIBUTE_CATEGORY of ELEMENT-638 and not Dummy Element Context.
    The BLD_BLK_INFO_TYPE_ID is correct though and the ATTRIBUTE to which it was saved is correct also. The BLD_BLK_INFO_TYPE_ID corresponds to Dummy Element Context.
    Why is the attribute_category not correct?

    Well would you believe it!? After much late night meddling around, I noticed one employee worked! There was absolutely no difference in any settings between his record and a persons who did not work. So I went into another employees record, changed his name and saved (correcting). Tried again and he worked fine! So, just by changing the employee name it seems to have worked for self service! I still cannot see them in timekeeper which is worrying however at least we can get time in for them now!
    If anyone knows why I may not be able to see them in timekeeper (even using an un-secured responsibility) then that would be a great help! :)

  • Use  LogRotationType="date" for WebServer in config.xml eats 99% CPU

    FYI. By accident I found out to set LogRotationType="date" for WebServer in config.xml eats 99%
    of CPU on my NT server constantly. To remove it fixed the problem. I don't understand why, assume
    this may be a bug.
    The is the setup I had for WebServer in my config.xml.
    <WebServer
    HttpsKeepAliveSecs="120"
    KeepAliveSecs="60"
    LogFileName="./config/myserver/logs/access.log"
    LogRotationType="date"
    LoggingEnabled="true"
    Name="myserver"
    Targets="myserver"
    />

    This looks like a bug for technical support. I suggest that you submit a
    bug report to [email protected]
    Be sure to include a complete test case.
    Michael Girdley
    BEA Systems
    Learning WebLogic? http://learnweblogic.com
    "Vivien" <[email protected]> wrote in message
    news:3a704ace$[email protected]..
    >
    FYI. By accident I found out to set LogRotationType="date" for WebServerin config.xml eats 99%
    of CPU on my NT server constantly. To remove it fixed the problem. Idon't understand why, assume
    this may be a bug.
    The is the setup I had for WebServer in my config.xml.
    <WebServer
    HttpsKeepAliveSecs="120"
    KeepAliveSecs="60"
    LogFileName="./config/myserver/logs/access.log"
    LogRotationType="date"
    LoggingEnabled="true"
    Name="myserver"
    Targets="myserver"
    />

  • How to send multiple data for a single element

    Hi All,
    I have a requirement where I have to send multiple data for single element per single transaction. For example
    Id details
    1 abcd
    1 efgh
    1 def
    Now, when I am selecting this ID from database, I have to get all the details in a single xsd like
    <id>1</id>
    ---><details>abcd</details>
    <details>efgh</details>
    <details>def</details>
    Thanks

    Hi,
    The following XSLT...
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    <xsl:variable name="root" select="/"/>
    <root>
    <xsl:for-each select="distinct-values(/root/entry/id)">
    <xsl:variable name="id" select="."/>
    <entry>
    <id><xsl:value-of select="$id"/></id>
    <xsl:for-each select="$root/root/entry[id = $id]">
    <details><xsl:value-of select="details"/></details>
    </xsl:for-each>
    </entry>
    </xsl:for-each>
    </root>
    </xsl:template>
    </xsl:stylesheet>Will work for a document like this...
    <root>
    <entry>
    <id>1</id>
    <details>detail1</details>
    </entry>
    <entry>
    <id>1</id>
    <details>detail2</details>
    </entry>
    <entry>
    <id>2</id>
    <details>detail3</details>
    </entry>
    </root>Hope this helps...
    Cheers,
    Vlad

  • Efficient searching in a large XML file for specific elements

    Hi
    How can I search in a large XML file for a specific element efficiently (fast and memory savvy?) I have a large (approximately 32MB with about 140,000 main elements) XML file and I have to search through it for specific elements. What stable and production-ready open source tools are available for such tasks? I think PDOM is a solution but I can't find any well-known and stable implementations on the web.
    Thanks in advance,
    Behrang Saeedzadeh.

    The problem with DOM parsers is that the whole document needs to be parsed!
    So with large documents this uses up a lot of memory.
    I suggest you look at sometthing like a pull parser (Piccolo or MPX1) which is a fast parser that is program driven and not event driven like SAX. This has the advantage of not needing to remember your state between events.
    I have used Piccolo to extract events from large xml based log files.
    Carl.

  • Error Error oracle.iam.platform.context.ContextManager BEA-000000 IAM-0030007 org.xml.sax.SAXParseException: Line 1, Column 1 : XML-20108: (Fatal Error) Start of root element expected. error in oim logs

    Hi ,
    I am getting the below error at times in oim logs not able to find the reason please help.
    <Error> <oracle.iam.platform.context.ContextManager> <BEA-000000> <IAM-0030007
    org.xml.sax.SAXParseException: <Line 1, Column 1>: XML-20108: (Fatal Error) Start of root element expected.
        at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:422)
        at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:287)
        at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:414)
        at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:355)
        at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:226)
    <XELLERATE.DATABASE> <BEA-000000> <Class/Method: tcDataBaseClient/bindToInstance encounter some problems: java.lang.ClassNotFoundException: weblogic/jndi/WLInitialContextFactory
    oracle.iam.platform.utils.ServiceInitializationException: java.lang.ClassNotFoundException: weblogic/jndi/WLInitialContextFactory
        at oracle.iam.platform.Platform.getService(Platform.java:265)
        at oracle.iam.platform.OIMInternalClient.getService(OIMInternalClient.java:188)
        at com.thortech.xl.dataaccess.tcDataBaseClient.bindToInstance(tcDataBaseClient.java:151)
        at com.thortech.xl.client.dataobj.tcDataBaseClient.recoverConnection(tcDataBaseClient.java:401)
        at com.thortech.xl.client.dataobj.tcDataBaseClient.getInterface(tcDataBaseClient.java:385)
        at com.thortech.xl.dataaccess.tcDataBaseClient.close(tcDataBaseClient.java:349)
        at com.thortech.xl.server.tcDataBaseClient.close(tcDataBaseClient.java:62)
        at com.thortech.xl.server.tcDataBaseClient.finalize(tcDataBaseClient.java:43
    Caused By: java.lang.ClassNotFoundException: weblogic/jndi/WLInitialContextFactory
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at com.sun.naming.internal.VersionHelper12.loadClass(Ve
    <Class/Method: tcDataBaseClient/getInterface encounter some problems: RuntimeException encountered. Reconnecting!
    java.lang.NullPointerException
        at oracle.iam.platform.context.ContextManager.getCounter(ContextManager.java:697)
        at oracle.iam.platform.context.ContextManager.incrementCounter(ContextManager.java:684)
    <Error> <XELLERATE.DATABASE> <BEA-000000> <Class/Method: tcDataBaseClient/close encounter some problems: Bean has been deleted.
    javax.ejb.NoSuchEJBException: Bean has been deleted.
    Thanks,
    Sahana

    hi Antara
    about "... Though I have imported the following JDK parsers in the code , the Oracle's SAX parser is taking other inside the application server ..."
    If you have used the SAXParserFactory.newSAXParser() method to get a parser, the documentation for this method says "Creates a new instance of a SAXParser using the currently configured factory parameters.".
    So you might get a different parser in a different environment.
    regards
    Jan Vervecken

  • Need to count number of non-empty (not null) occurrences for an element in XML

    Hello,
        I have some XML data stored in a CLOB, there is a fragment shown below:
    <ADDR>
    <AutoNameOfOrganisation>2nd Image</AutoNameOfOrganisation>
    <AutoLine1>105 Risbygate Street</AutoLine1>
    <AutoLine2> </AutoLine2>
    <AutoLine3> </AutoLine3>
    <AutoU40.16>BURY ST. EDMUNDS</AutoU40.16>
    <AutoStateOrCounty>Suffolk</AutoStateOrCounty>
    <AutoU40.13>IP33 3AA</AutoU40.13>
    <AutoU40.14>UNITED KINGDOM</AutoU40.14>
    </ADDR>
    <ADDR>
    <AutoNameOfOrganisation></AutoNameOfOrganisation>
    <AutoLine1>2 2nd Avenue</AutoLine1>
    <AutoLine2> </AutoLine2>
    <AutoLine3> </AutoLine3>
    <AutoU40.16>HULL</AutoU40.16>
    <AutoStateOrCounty>East Riding of Yorkshire</AutoStateOrCounty>
    <AutoU40.13>HU6 9NT</AutoU40.13>
    <AutoU40.14>UNITED KINGDOM</AutoU40.14>
    </ADDR>
       What I would like to do is to be able to look at the whole of the xml and derive a count for a particular element where there is data .
       In the above case <AutoNameOfOrganisation> is not null in the first record and null in the second whilst <AutoLine3> is null in both records, so I'd like the counts to be 1 for <AutoNameOfOrganisation> and 0 for <AutoLine3>.
       The reason for this is so that I can avoid showing a column in a report if there is no data for that particular column in the results.
       I'm using Oracle 11G.
    Thanks for any help,
    Chris

    Here's one way :
    select count(AutoNameOfOrganisation)
         , count(AutoLine3)
    from my_table t
       , xmltable(
           '/root/ADDR'
           passing xmlparse(document my_clob)
           columns AutoNameOfOrganisation varchar2(30) path 'normalize-space(AutoNameOfOrganisation)'
                 , AutoLine3              varchar2(30) path 'normalize-space(AutoLine3)'
         ) x ;
    In your sample fragment there's no root element so I've added one to test the query (though it's also possible to work with real XML fragments).
    You may also omit normalize-space() calls if empty nodes are really empty. In your sample, there's a whitespace so I've added the function to strip it off.

  • How to send PR & PO data for materials through IDOC in XML

    Hi Experts,
    I am looking for a solution to send open PR & open PO related data for diffrent materials through as IDCO in XML file.
    Scenario is i have to show a report in a 3rd party system for open PR & open PR that too will come after selection some materials. That means select a materials & it will show all the open PO & related data in a report.
    The rough idea for the solution i got is I can save the data in XML file in the system. For this i have to send IDOC. but the problem is there is no message type for PR. IF i am not wrong i can extend the MATMAS05 for a segment that will have PR related info.
    Now what to do with that how to send the IDOC do i need to create another report to send IDOC or i can send the extended one through BD10. I tried it but it shows error message "0 communication idoc sent" so I dont no y such error is coming i think i am not filling the extended idoc. But again my QUestion is how to do that. If anyone have any other solution Please help me out of this.
    Regards,
    Nik

    Hi Alpesh,
    Thanks for your reply.
    My requirement is bit different. i have to send Open PR data for diffrent materials. In a 3rd party application user will search for few materials which will generate a report that will show the PR related data for those material.
    Same thing i have to do for PO & Sales order also.
    Can u please help me to provide the solution how can i proceed for it. U have given the Message type & a bapi how it will help in my issue?
    I got a suggesion from someone that extend message type matmas for PR, PO, SD related data & send the idoc. but i am confused how to pass that much data ina single IDOC.
    Regards,
    Nik

  • Imported XSLT cannot create attributes for generated XML element

    I have two xslts. One imports the other.
    The imported xslt creates XML elements with attributes and this XML is stored in a variable in the main stylesheet
    If I perform the transformation with JRE prior to 1.6.0.18 then all works fine
    If I use 1.6.0.18 or 1.6.0.19 then the attributes aren't added.
    If I add attributes in the main xslt it works fine or if I output the element directly instead of first storing it in a variable then it also works fine.
    Problem seems to be when you try to add attributes from an imported stylesheet and store the generated element in a variable.
    Below two stylesheets to illustrate :
    First MainStylesheet.xsl
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Copyright 1993-2005 Seagull Software Systems, Inc. -->
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:exsl="http://exslt.org/common"
    extension-element-prefixes="exsl"
    exclude-result-prefixes="xs">
    <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
    <xsl:import href="innerstylesheet.xsl"/>
    <xsl:template match="/TestData">
    <xsl:variable name="generatedElementXml">
    <xsl:call-template name="generateElement">
    <xsl:with-param name="s">testValue</xsl:with-param>
    </xsl:call-template>
    </xsl:variable>
    <xsl:for-each select="exsl:node-set($generatedElementXml)">
    *** GeneratedElementXML {<xsl:text>
    </xsl:text><xsl:copy-of select="*"></xsl:copy-of>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>Next innerstylesheet.xsl
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:exsl="http://exslt.org/common"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    extension-element-prefixes="exsl" >
            <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
            <xsl:template name="generateElement">
                       <xsl:param name="s"/>
                    <TestElement testAttribute="$s" />
            </xsl:template>
    </xsl:stylesheet>The result output by jres before 1.6.0.18 is :
    <?xml version="1.0" encoding="UTF-8"?>
                   *** GeneratedElementXML {
              <TestElement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" testAttribute="testValue"/>
                   }          The result output by jres since 1.6.0.18 is :
    <?xml version="1.0" encoding="UTF-8"?>
                   *** GeneratedElementXML {
              <TestElement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                   }          Note : the 'testAttribute' attribute is missing

    Have found the difference in the code
    In both JRE1.6.0_17 & JRE1.6.0_18, the class 'com.sun.org.apache.xalan.internal.xsltc.dom.AdaptiveResultTreeImpl' has the following method
    public void addUniqueAttribute(String qName, String value, int flags)
            throws SAXException
            addAttribute(qName, value);
        }In JRE1.6.0_17 the next method is
    public void addAttribute(String name, String value)
         if (_openElementName != null) {
             _attributes.add(name, value);
         else {
             BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR, name);
        }In JRE1.6.0_18 the next method is
    public void addAttribute(String uri, String localName, String qname,
                String type, String value)
         if (_openElementName != null) {
             _attributes.addAttribute(uri, localName, qname, type, value);
         else {
             BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR, qname);
        }Note - the addAttribute method has additional parameters in JRE1.6.0_18 but the call from addUniqueAttribute wasn't updated.
    So in JRE1.6.0_18 addUniqueAttribute actually invokes the following method in the base package com.sun.org.apache.xml.internal.serializer.EmptySerializer
    public void addAttribute(String name, String value)
            aMethodIsCalled();
    void aMethodIsCalled()
            // throw new RuntimeException(err);
            return;
        }and as you can see this does nothing. Hence the fact that the attribute isn't added.

  • Uniqueness for xml element is not validated with the xsd:unique

    Hi
    I am using <xsd:unique> to specify uniqueness for certain elements in the schema. But when i create the xml for the schema,it allows me to create elements with duplicate values for which the uniqueness is defined and also it is allowed to parse the xml correctly.I am using jaxb2.0 and jaxp2.0 to bind the xml and parse it. The schema is described below :
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <xsd:include schemaLocation="ArtifactDetails.xsd" />
         <xsd:element name="EKMArtifacts">
              <xsd:complexType>
                   <xsd:sequence>
                        <xsd:element name="Artifact" minOccurs="0" maxOccurs="unbounded">
                             <xsd:complexType>
                                  <xsd:sequence>
                                       <xsd:element name="ArtifactType" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="ArtifactName" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="Status" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="VersionString" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="Artifactdesc" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="Functionaldesc" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="Department" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="Location" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="Rated" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="Category" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="Createdby" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="OSPlatform" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="APPPlatform" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="Country" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="State" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element name="Vendor" type="xsd:string" nillable="false" minOccurs="1" maxOccurs="1" />
                                       <xsd:element ref="ArtifactDetails" minOccurs="0" maxOccurs="1" />
                                  </xsd:sequence>
                             </xsd:complexType>
                        </xsd:element>
                   </xsd:sequence>
              </xsd:complexType>
              <xsd:unique name="ArtifactNameUnique">
                   <xsd:selector xpath="Artifact" />
                   <xsd:field xpath="ArtifactName" />
              </xsd:unique>
         </xsd:element>
    </xsd:schema>
    Can anyone help me out
    Thanks in advance

    Well there's nothing wrong with your schema (I copyied it into XMLSpy and wasn't able to create two artifacts with the same name). My guess is that JAXB still does not support xsd:unqiue
    http://www.onjava.com/pub/a/onjava/2004/12/15/jaxb.html

  • Multi-level nested tables for repeatable XML Elements

    Hi there,
    Suppose we have a XML Schema „ASchema“ like this (XMLDB schema annotations are left out for simplicity):
    <xs:schema xmlns:xs=" .... " />
    <xs:element name=“A“>
         <xs:complexType>
              <xs:sequence>
                   <xs:element name=“B“ maxOccurs=“unbounded“/>
                        <xs:complexType>
                             <xs:sequence>
                                  <xs:element name = “C“ maxOccurs=“unbounded“/>
                             </xs:sequence>
                        </xs:complexType>
                   </xs:element>
              </xs:sequence>
         </xs:complexType>
    </xs:element>
    </xs:schema>
    After registering this schema in Oracle, I can define a table like this:
    CREATE TABLE ATable
    id NUMBER,
    doc XMLTYPE
    XMLTYPE COLUMN doc
    XMLSCHEMA “ASchema“ ELEMENT “A“
    VARARRAY doc.“XMLDATA“.“B“ STORE AS TABLE “BTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    This creates a nested table "BTable" within the table "ATable". So far so good, I can use this nested table to gain faster access on every possible subelement of Element B when I set an appropriate index.
    I now want to create another nested table for element “C“ like this:
    DROP TABLE ATable;
    CREATE TABLE ATable
    id NUMBER,
    doc XMLTYPE
    XMLTYPE COLUMN doc
    XMLSCHEMA “ASchema“ ELEMENT “A“
    VARARRAY doc.“XMLDATA“.“B“ STORE AS TABLE “BTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    VARARRAY doc.“XMLDATA“.“B“.“C“ STORE AS TABLE “CTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    But this statement fails with the error message something like „ ... no such attribute ... „
    And here's my question: is it possible to create nested tables for repeatable XML Elements that are subelements of other repeatable XML Elements ? And if so, how can I do it ?
    Thank you very much in advance
    Jan

    Found a (partial) solution myself:
    If you add the attribute xdb:storeVarrayAsTable="true" to the root element of the XML schema, Oracle XMLDB generates nested tables for all repeatable XML Elements while registering the XML schema.
    Unfortunately, the names of these nested tables are system-generated, hence it's a bit uncomfortable to set indices on them. You can find out the names of these nested tables as follows:
    select table_name, parent_table_name, parent_table_column from user_nested_tables;
    Further information on that subject is supplied in the following thread:
    Re: default tables for elements with maxoccurs > 1
    It would be nice if there was a way to name the generated nested tables via appropriate XMLDB schema annotations.
    regards
    Jan

Maybe you are looking for