当前位置: 首页>>代码示例>>Java>>正文


Java WstxInputFactory.configureForConvenience方法代码示例

本文整理汇总了Java中com.ctc.wstx.stax.WstxInputFactory.configureForConvenience方法的典型用法代码示例。如果您正苦于以下问题:Java WstxInputFactory.configureForConvenience方法的具体用法?Java WstxInputFactory.configureForConvenience怎么用?Java WstxInputFactory.configureForConvenience使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ctc.wstx.stax.WstxInputFactory的用法示例。


在下文中一共展示了WstxInputFactory.configureForConvenience方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseIndexFromFile

import com.ctc.wstx.stax.WstxInputFactory; //导入方法依赖的package包/类
/** 
 * Creates a new instance of Index Of Model Mappings read from the corresponding file
 * (Used for persistence)
 */
public static void parseIndexFromFile() {
    // Read file and create the Index
    // check if file exists. If it exists open it and parse it. 
    // Else return
    //
    File inFile = new File(Model3dIndex.getIndexPath()+"modelIndex.xml");
    // error state check
    if(inFile.exists())
    {
        try{
            Model3dIndex.getListofAllMetaEntries().clear();
            FileReader tmpInReader = new FileReader(inFile);
            WstxInputFactory fin = new WstxInputFactory();
            fin.configureForConvenience();
            fin.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); // <-- NEEDED TO GET ATTRIBUTES!
            // input
            XMLStreamReader2 sr = (XMLStreamReader2)fin.createXMLStreamReader(tmpInReader);
            SMInputCursor inputRootElement = SMInputFactory.rootElementCursor(sr);
            inputRootElement.getNext();
            SMInputCursor childInElement = inputRootElement.childCursor();
            String myText="";
            while (childInElement.getNext() != null) {
                if(!childInElement.getCurrEvent().hasText() &&
                        childInElement.getLocalName().toLowerCase().equals(Model3dIndex.getMetaEntryTag().toLowerCase() ) ) 
                {
                    Model3dIndex.getListofAllMetaEntries().add(new Model3dIndexEntry(childInElement));
                }
            }
            tmpInReader.close();
        }
        catch(Exception e)
        {
            return;
        }
    }
    else
        return;
}
 
开发者ID:vitrofp7,项目名称:vitro,代码行数:43,代码来源:Model3dIndex.java

示例2: parseMetafileFromFile

import com.ctc.wstx.stax.WstxInputFactory; //导入方法依赖的package包/类
/** 
 * Creates a new instance of Metafile entry read from the corresponding file
 * (Used for persistence)
 */
public static Model3dMetafile parseMetafileFromFile(String filenameAndPath) {
    // Read file and create the Metafile entry
    // check if file exists. If it exists open it and parse it. 
    // Else return
    //
    File inFile = new File(filenameAndPath);
    // error state check
    if(inFile.exists())
    {
        try{               
            // read from file
            FileReader tmpInReader = new FileReader(inFile);
            WstxInputFactory fin = new WstxInputFactory();
            fin.configureForConvenience();
            fin.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); // <-- NEEDED TO GET ATTRIBUTES!
            // input
            XMLStreamReader2 sr = (XMLStreamReader2)fin.createXMLStreamReader(tmpInReader);
            SMInputCursor inputRootElement = SMInputFactory.rootElementCursor(sr);
            inputRootElement.getNext();
            Model3dMetafile metaFileToReturn = new Model3dMetafile(inputRootElement); 
            tmpInReader.close(); 
            return metaFileToReturn;
            
        }
        catch(Exception e)
        {
            return null;
        }
    }
    else
        return null;
}
 
开发者ID:vitrofp7,项目名称:vitro,代码行数:37,代码来源:Model3dMetafile.java

示例3: parseStylesIndexFromFile

import com.ctc.wstx.stax.WstxInputFactory; //导入方法依赖的package包/类
/**
 * Creates a new instance of Index Of Styles read from the corresponding file
 * (Used for persistence)
 */
public static void parseStylesIndexFromFile() {
    // Read file and create the Index
    // check if file exists. If it exists open it and parse it.
    // Else return
    //
    File inFile = new File(Model3dStylesList.getIndexFilenameandPath());
    // error state check
    if(inFile.exists()) {
        try{
            Model3dStylesList.getListofStyleEntriesVec().clear();
            FileReader tmpInReader = new FileReader(inFile);
            WstxInputFactory fin = new WstxInputFactory();
            fin.configureForConvenience();
            fin.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); // <-- NEEDED TO GET ATTRIBUTES!
            // input
            XMLStreamReader2 sr = (XMLStreamReader2)fin.createXMLStreamReader(tmpInReader);
            SMInputCursor inputRootElement = SMInputFactory.rootElementCursor(sr);
            inputRootElement.getNext();
            SMInputCursor childInElement = inputRootElement.childCursor();
            String myText="";
            while (childInElement.getNext() != null) {
                if(!childInElement.getCurrEvent().hasText() &&
                        childInElement.getLocalName().toLowerCase().equals(Model3dStylesList.getStyleEntryTag().toLowerCase() ) ) {
                    Model3dStylesList.getListofStyleEntriesVec().add(new Model3dStylesEntry(childInElement));
                }
            }
            tmpInReader.close();
        } catch(Exception e) {
            return;
        }
    } else
        return;
}
 
开发者ID:vitrofp7,项目名称:vitro,代码行数:38,代码来源:Model3dStylesList.java

示例4: appendUniqueMergedStylesHeader

import com.ctc.wstx.stax.WstxInputFactory; //导入方法依赖的package包/类
private static void appendUniqueMergedStylesHeader(SMOutputElement outputDocumentEl, Set<String> givFilenameKeys, PrintWriter outPrintWriter, String realPath) {
    Vector<String> uniqueStyleIdsVec = new Vector<String>();

    Iterator<String> itFilenames = givFilenameKeys.iterator();
    try{
        while(itFilenames.hasNext()) {
            String tmpFilename = itFilenames.next();
            //outPrintWriter.print(realPath+File.separator+"KML"+File.separator+ tmpFilename);
            File inFile = new File(realPath+File.separator+"Models"+File.separator+"Large"+File.separator+ tmpFilename);
            FileReader tmpInReader = new FileReader(inFile);
            WstxInputFactory fin = new WstxInputFactory();
            fin.configureForConvenience();
            fin.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); // <-- NEEDED TO GET ATTRIBUTES!
            // input
            XMLStreamReader2 sr = (XMLStreamReader2)fin.createXMLStreamReader(tmpInReader);
            SMInputCursor inputRootElement = SMInputFactory.rootElementCursor(sr);
            inputRootElement.getNext();
            SMInputCursor inputDocumentElement = inputRootElement.childCursor();
            while(inputDocumentElement.getNext()!=null ) {
                if( !inputDocumentElement.getCurrEvent().hasText() ) {
                    SMInputCursor childInputUnderDocu = inputDocumentElement.childMixedCursor();
                    while(childInputUnderDocu.getNext()!=null )
                    {
                        if(childInputUnderDocu.getCurrEvent().hasText() ) {
                            ; // ignore it
                        } 
                        else // if is not text
                        {
                            if(childInputUnderDocu.getLocalName().equals("Style")) {
                                if(!uniqueStyleIdsVec.contains(childInputUnderDocu.getAttrValue("id")) ) {
                                    uniqueStyleIdsVec.add(childInputUnderDocu.getAttrValue("id"));
                                    SMOutputElement outputInsideDocumentEl = null;
                                    outputInsideDocumentEl = outputDocumentEl.addElement("Style");
                                    SMTools.cloneAllAttributestoOutputElement(outputInsideDocumentEl, childInputUnderDocu);
                                    parseXMLperLevel(outputInsideDocumentEl, childInputUnderDocu);
                                }
                            }
                        }
                    }
                    break; //only one document element allowed.
                }
            }
            tmpInReader.close();
        }
    } catch (Exception e) {
       ;// outPrintWriter.print("ERROR: "+e.getMessage());
    }
}
 
开发者ID:vitrofp7,项目名称:vitro,代码行数:49,代码来源:KMLResultFileTools.java

示例5: previewModel

import com.ctc.wstx.stax.WstxInputFactory; //导入方法依赖的package包/类
private void previewModel(HttpServletResponse response, File inFile) throws IOException
{
  PrintWriter outPrintWriter = response.getWriter();

  FileReader tmpInReader = new FileReader(inFile);
  WstxInputFactory fin = new WstxInputFactory();
  fin.configureForConvenience();
  fin.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); // <-- NEEDED TO GET ATTRIBUTES!
  
  //response.setContentType("text/xml");  // for debug
  //response.setHeader("Content-disposition","attachment; filename=\"previewModel.xml\""); // for debug
  response.setContentType("text/kml");
  response.setHeader("Content-disposition","inline; filename=\"previewModel.kml\"");

  //response.setHeader("Content-disposition","attachment; filename=\"previewModel.kml\"");
  //response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 <-- causes problems in explorer
  response.setHeader("Pragma", "public"); //HTTP 1.0 
  response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
  
  WstxOutputFactory fout = new WstxOutputFactory();    
  fout.configureForXmlConformance();    
  SMOutputDocument doc = null;
  SMOutputElement outputRootEl = null;
  try{        
      // output
      XMLStreamWriter2 sw = (XMLStreamWriter2)fout.createXMLStreamWriter(outPrintWriter);   
      doc = SMOutputFactory.createOutputDocument(sw, "1.0", "UTF-8", true);
      // Need to store some information about preceding siblings,
      // so let's enable tracking. (to do) maybe we don't need this)
      //
      //    it.setElementTracking(SMInputCursor.Tracking.VISIBLE_SIBLINGS);
      // input
      XMLStreamReader2 sr = (XMLStreamReader2)fin.createXMLStreamReader(tmpInReader);
      SMInputCursor inputRootElement = SMInputFactory.rootElementCursor(sr);
      inputRootElement.getNext();
      
      doc.setIndentation("\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t", 2, 1);
      outputRootEl = doc.addElement(inputRootElement.getLocalName());
      // Defines linefeed to use, tabs for indentation (from 2, step by 1)
      SMTools.cloneAllAttributestoOutputElement(outputRootEl, inputRootElement);
      
      parseXMLperLevel(outputRootEl, inputRootElement);               
      doc.closeRoot();
      tmpInReader.close();
  }
  catch(Exception e)
  {
          // apparently we can do this (re-set the content-type and disposition. It works with Mozilla and Opera.
          // IT DOES NOT work with Explorer who goes on to read the KML created.
          response.setContentType("text/xml");  // for debug          
          response.setHeader("Content-disposition","attachment; filename=\"ErrorInPreviewModel.xml\""); // for debug
          outPrintWriter.print("Error:"+e.getMessage());
  }    
  outPrintWriter.flush();
  outPrintWriter.close();
}
 
开发者ID:vitrofp7,项目名称:vitro,代码行数:57,代码来源:ModelCreator.java


注:本文中的com.ctc.wstx.stax.WstxInputFactory.configureForConvenience方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。