Examples of XMLType


Examples of org.teiid.core.types.XMLType

    }

  private static SQLXML jsonToXml(CommandContext context,
      final String rootName, final Reader r) throws TeiidComponentException,
      TeiidProcessingException {
    XMLType result = new XMLType(XMLSystemFunctions.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
     
      @Override
      public void translate(Writer writer) throws TransformerException,
          IOException {
          try {
            JSONParser parser = new JSONParser();
          XMLOutputFactory factory = getOutputFactory();
          final XMLStreamWriter streamWriter = factory.createXMLStreamWriter(writer);
           
          parser.parse(r, new JsonToXmlContentHandler(escapeName(rootName, true), streamWriter));
           
          streamWriter.flush(); //woodstox needs a flush rather than a close
        } catch (XMLStreamException e) {
          throw new TransformerException(e);
        } catch (ParseException e) {
          throw new TransformerException(e);
        } finally {
            try {
              r.close();
            } catch (IOException e) {
             
            }
          }
      }
    }));
    result.setType(Type.DOCUMENT);
    return result;
  }
View Full Code Here

Examples of org.teiid.core.types.XMLType

    }
 
  @Test public void testInvokeXmlConcat() throws Exception {
        CommandContext c = new CommandContext();
        c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
        XMLType result = (XMLType)helpInvokeMethod("xmlconcat", new Class<?>[] {DataTypeManager.DefaultDataClasses.XML, DataTypeManager.DefaultDataClasses.XML},
            new Object[] {DataTypeManager.transformValue("<bar/>", DataTypeManager.DefaultDataClasses.XML), DataTypeManager.transformValue("<Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", DataTypeManager.DefaultDataClasses.XML)}, c);
       
        String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
        assertEquals("<bar/><Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", xml);
    }
View Full Code Here

Examples of org.teiid.core.types.XMLType

    }
 
  @Test public void testInvokeXmlComment() throws Exception {
        CommandContext c = new CommandContext();
        c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
        XMLType result = (XMLType)helpInvokeMethod("xmlcomment", new Class<?>[] {DataTypeManager.DefaultDataClasses.STRING},
            new Object[] {"comment"}, c);
       
        String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
        assertEquals("<!--comment-->", xml);
    }
View Full Code Here

Examples of org.teiid.core.types.XMLType

      }
      return new BlobType(new BlobImpl(fsisf));
    }
    if (value instanceof Source) {
      if (value instanceof InputStreamFactory) {
        return new XMLType(new SQLXMLImpl((InputStreamFactory)value));
      }
      StandardXMLTranslator sxt = new StandardXMLTranslator((Source)value);
      SQLXMLImpl sqlxml;
      try {
        sqlxml = XMLSystemFunctions.saveToBufferManager(dtm.getBufferManager(), sxt);
      } catch (TeiidComponentException e) {
        throw new TeiidRuntimeException(e);
      } catch (TeiidProcessingException e) {
        throw new TeiidRuntimeException(e);
      }
      return new XMLType(sqlxml);
    }
    return DataTypeManager.convertToRuntimeType(value);
  }
View Full Code Here

Examples of org.teiid.core.types.XMLType

          //props.setProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
          props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
          QueryResult.serializeSequence(iter.getAnother(), config, writer, props);
      }
    });
    XMLType value = new XMLType(xml);
    value.setType(type);
    return value;
  }
View Full Code Here

Examples of org.teiid.core.types.XMLType

           
            //handle xml
            if(record.size() == 1){
              Object cellValue = record.get(0);
              if(cellValue instanceof XMLType){
                    XMLType id =  (XMLType)cellValue;
                    String actualDoc = id.getString();
                  if (expectedResults[i].size() == 1) {
                    compareDocuments((String)expectedResults[i].get(0), actualDoc);
                        continue;
                  }
              }
View Full Code Here

Examples of org.teiid.core.types.XMLType

                //code to check for end of document, set current doc
                //to null, and return the finished doc as a single tuple
                DocumentInProgress doc = env.getDocumentInProgress();
                if (doc != null && doc.isFinished()) {
                    this.env.setDocumentInProgress(null);
                    XMLType xml = new XMLType(doc.getSQLXML());
                    // check to see if we need to do any post validation on the document.
                    if (getContext().validateXML()){
                      Reader reader;
                  try {
                    reader = xml.getCharacterStream();
                  } catch (SQLException e) {
                    throw new TeiidComponentException(e);
                  }
                      try {
                        validateDoc(reader);
View Full Code Here

Examples of org.teiid.core.types.XMLType

   
    @Test public void testXML() throws Exception {
      StatementImpl statement = createMockStatement(ResultSet.TYPE_FORWARD_ONLY);
      ResultsFuture<LobChunk> future = new ResultsFuture<LobChunk>();
      future.getResultsReceiver().receiveResults(new LobChunk("<a/>".getBytes(Charset.forName("UTF-8")), true));
      XMLType result = new XMLType();
      Mockito.stub(statement.getDQP().requestNextLobChunk(0, 0, result.getReferenceStreamId())).toReturn(future);
        ResultsMessage resultsMsg = new ResultsMessage();
        result.setEncoding("UTF-8");
        resultsMsg.setResults(new List<?>[] {Arrays.asList(result)});
        resultsMsg.setLastRow(1);
        resultsMsg.setFirstRow(1);
        resultsMsg.setFinalRow(1);
        resultsMsg.setColumnNames(new String[] {"x"}); //$NON-NLS-1$
View Full Code Here

Examples of org.teiid.core.types.XMLType

              tuple.add(null);
            }
            continue;
          }
          if (proColumn.getSymbol().getType() == DataTypeManager.DefaultDataClasses.XML) {
            XMLType value = table.getXQueryExpression().createXMLType(pathIter.getAnother(), this.getBufferManager(), false);
            tuple.add(value);
            continue;
          }
          if (pathIter.next() != null) {
            throw new TeiidProcessingException(QueryPlugin.Util.getString("XMLTableName.multi_value", proColumn.getName())); //$NON-NLS-1$
View Full Code Here

Examples of org.teiid.core.types.XMLType

      }
      else if (lob instanceof ClobType) {
        persistedLob = new ClobType(new ClobImpl(isf, ((ClobType)lob).length()));
      }
      else {
        persistedLob = new XMLType(new SQLXMLImpl(isf));
        ((XMLType)persistedLob).setEncoding(((XMLType)lob).getEncoding());
        ((XMLType)persistedLob).setType(((XMLType)lob).getType());
      }
    } catch (SQLException e) {
      throw new TeiidComponentException(e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.