首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >saxon 9企业向国内版转型后的问题

saxon 9企业向国内版转型后的问题
EN

Stack Overflow用户
提问于 2016-01-14 10:59:28
回答 1查看 147关注 0票数 0

我们用过撒克逊企业社论。现在我们已经没有许可证了,因此我不得不从应用程序中删除一个jar文件(saxon9ee)。

当我删除这个jar文件并添加一个saxon9 9-he时,我们的一个函数停止工作。我们有一个链接,用产品创建xml文件,然后在网站上用html发布。xml文件仍在创建,但发布部分正在失败。它只是显示了一个空白页。

一旦我添加了saxon9ee,它就会再次工作。但我们不能再用这个jar文件了。

正因为如此,我猜这与DOMSource (XSLT?)的转换有关。但我不知道是什么部分失败了,因为失去了Saxon9ee。我没有例外。有什么好的方法来取代我在删除时丢失的功能吗?

守则:

代码语言:javascript
复制
public String publishXmlFile(AS400 as400) {
        try {

            init();

            build();

            CatalogListController ac = (CatalogListController) FacesUtils.getManagedBean(BeanNames.CATALOG_LIST_CONTROLLER);
            Catalog catalog = new Catalog(ac.getSelectedCatalog().getCatalogUi());
            addCatalog(catalog);

            String ifsPath = ApplicationProperties.getString("AS400ExportPath") + "internal/";

            String fileName = ifsPath + ac.getSelectedCatalog().getUrlCode() + ".xml";

            IFSFile xmlFile = new IFSFile(as400, fileName);


            if (!xmlFile.exists()) {
                xmlFile.createNewFile();
            }

            if (xmlFile.exists()) {
                xmlFile.setCCSID(1208);
                IFSFileOutputStream fos;

                try {

                    fos = new IFSFileOutputStream(xmlFile);

                    // Prepare the DOM document for writing
                    Source source = new DOMSource(document);

                    // Prepare the output file

                    Result result = new StreamResult(fos);

                    // Write the DOM document to the file
                    Transformer xformer = TransformerFactory.newInstance().newTransformer();
                    xformer.setOutputProperty("encoding", "utf-8");
                    xformer.setOutputProperty(OutputKeys.INDENT, "yes");

                    xformer.transform(source, result);

                    System.out.println(source.toString() + " " + result.toString());

                    System.out.println("XML-FILE: " + xmlFile.toString());

                    fos.close();

                    xmlFile = null;
                } catch (TransformerConfigurationException e) {
                    e.printStackTrace();
                } catch (TransformerException e) {
                    e.printStackTrace();
                }

            } else {
                System.out.println(xmlFile.getAbsolutePath() + " ");

            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

intit()函数:

代码语言:javascript
复制
private void init() {
    // Setup Doc
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        document = builder.newDocument();
        document.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" ");
        domRoot = (Element) document.createElement("xKml");
        document.appendChild(domRoot);
        domRoot.setAttribute("xsi:schemaLocation",  "urn:company:xKml:2:0 http://www99.company.com/schemas/xKml-2-0/xKml-2-0.xsd");
        domRoot.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
        //domRoot.setAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema");
        domRoot.setAttribute("xmlns", "urn:company:xKml:2:0");

        timeFormatter.setTimeZone(TimeZone.getDefault());
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    }
}

xsd文件(http://www99.company.com/schemas/xKml-2-0/xKml-2-0.xsd):

代码语言:javascript
复制
<xsd:schema targetNamespace="urn:company:xKml:2:0" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2:0">
    <xsd:include schemaLocation="../xKml-2-0-1/common/xKml-Components-2-0-1.xsd"/>

    <!--xsd:include schemaLocation="common/xKml-CommonComponents-2-0.xsd"/
    -->

    <xsd:include schemaLocation="../xKml-2-0-1/Order-2-0-1.xsd"/>
    <xsd:include schemaLocation="../xKml-2-0-1/Invoice-2-0-1.xsd"/>
    <xsd:include schemaLocation="../xKml-2-0-1/Catalog-2-0-1.xsd"/>
    <xsd:include schemaLocation="../xKml-2-0-1/PurchaseForecast-2-0-1.xsd"/>
    <xsd:include schemaLocation="../xKml-2-0-1/OrderResponse-2-0-1.xsd"/>
    <xsd:include schemaLocation="../xKml-2-0-1/OrderChanges-2-0-1.xsd"/>
    <xsd:include schemaLocation="../xKml-2-0-1/ControlMessage-2-0-1.xsd"/>

    <!--

    <xsd:include schemaLocation="documents/xKml-OrderDocument-2-0.xsd"/>
    <xsd:include schemaLocation="documents/xKml-InvoiceDocument-2-0.xsd"/>
    <xsd:include schemaLocation="documents/xKml-CatalogDocument-2-0.xsd"/>
    <xsd:include schemaLocation="documents/xKml-PurchaseForecastDocument-2-0.xsd"/>
    <xsd:include schemaLocation="documents/xKml-OrderResponseDocument-2-0.xsd"/>
    <xsd:include schemaLocation="documents/xKml-OrderChangesDocument-2-0.xsd"/>
    <xsd:include schemaLocation="common/xKml-ControlWorkdataMessages-2-0.xsd"/>

--><!--                 -->
<!-- xKml   -->
<!--                    -->
<xsd:element name="xKml">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element ref="Version"/>
            <xsd:element ref="History"/>
            <xsd:choice>
                <xsd:sequence>
                    <xsd:element ref="Parameter" minOccurs="0" maxOccurs="unbounded"/>
                    <xsd:element ref="Interchange"/>
                    <xsd:element name="Documents">
                        <xsd:complexType>
                            <xsd:sequence>
                                <xsd:choice>
                                    <xsd:element ref="Catalog" minOccurs="0" maxOccurs="unbounded"/>
                                    <xsd:element ref="PurchaseForecast" minOccurs="0" maxOccurs="unbounded"/>
                                    <xsd:element ref="Order" minOccurs="0" maxOccurs="unbounded"/>
                                    <xsd:element ref="OrderResponse" minOccurs="0" maxOccurs="unbounded"/>
                                    <xsd:element ref="OrderChanges" minOccurs="0" maxOccurs="unbounded"/>
                                    <xsd:element ref="Invoice" minOccurs="0" maxOccurs="unbounded"/>
                                </xsd:choice>
                            </xsd:sequence>
                        </xsd:complexType>
                    </xsd:element>
                </xsd:sequence>
                <xsd:element ref="ControlMessage"/>
            </xsd:choice>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>
</xsd:schema>

build()函数:

代码语言:javascript
复制
private void build() {
        Element e, e1, e2, e3;

        // basic sceleton for DOMtree
        e = (Element) document.createElement("Version");
        e.setAttribute("xmlns", "urn:company:xKml:2:0");
        domRoot.appendChild(e);
        e.appendChild(document.createTextNode("02.00"));

        e = (Element) document.createElement("History");
        e.setAttribute("xmlns", "urn:company:xKml:2:0");
        domRoot.appendChild(e);

        e1 = document.createElement("HistoryRecord");
        e1.setAttribute("xmlns", "urn:company:xKml:2:0");
        e.appendChild(e1);

        e2 = document.createElement("Process");
        e2.setAttribute("xmlns", "urn:company:xKml:2:0");
        e1.appendChild(e2);
        e2.appendChild(document.createTextNode("B2B"));

        e2 = document.createElement("Timestamp");
        e2.setAttribute("xmlns", "urn:company:xKml:2:0");
        e1.appendChild(e2);

        e3 = document.createElement("Date");
        e3.setAttribute("xmlns", "urn:company:xKml:2:0");
        e2.appendChild(e3);
        e3.appendChild(document.createTextNode(dateFormatter.format(new Date())));

        e3 = document.createElement("Time");
        e3.setAttribute("xmlns", "urn:company:xKml:2:0");
        e2.appendChild(e3);
        e3.appendChild(document.createTextNode(timeFormatter.format(new Date())));

        e = (Element) document.createElement("Interchange");
        e.setAttribute("xmlns", "urn:company:xKml:2:0");
        domRoot.appendChild(e);

        e1 = document.createElement("InterchangeIdentity");
        e1.setAttribute("xmlns", "urn:company:xKml:2:0");
        e.appendChild(e1);
        e1.appendChild(document.createTextNode(dateFormatter.format(new Date()) + " "  + timeFormatter.format(new Date())));

        e1 = document.createElement("Timestamp");
        e1.setAttribute("xmlns", "urn:company:xKml:2:0");
        e.appendChild(e1);

        e2 = document.createElement("Date");
        e2.setAttribute("xmlns", "urn:company:xKml:2:0");
        e1.appendChild(e2);
        e2.appendChild(document.createTextNode(dateFormatter.format(new Date())));

        e2 = document.createElement("Time");
        e2.setAttribute("xmlns", "urn:company:xKml:2:0");
        e1.appendChild(e2);
        e2.appendChild(document.createTextNode(timeFormatter.format(new Date())));

        e1 = document.createElement("ComPartners");
        e1.setAttribute("xmlns", "urn:company:xKml:2:0");
        e.appendChild(e1);

        e2 = document.createElement("From");
        e2.setAttribute("xmlns", "urn:company:xKml:2:0");
        e1.appendChild(e2);

        e2 = document.createElement("To");
        e2.setAttribute("xmlns", "urn:company:xKml:2:0");
        e1.appendChild(e2);

        e1 = document.createElement("DeploymentMode");
        e1.setAttribute("xmlns", "urn:company:xKml:2:0");
        e.appendChild(e1);

        e1.appendChild(document.createTextNode("Operational"));


    }

addCatalog()使用与build()相同的方法和标准。

在其工作的应用程序版本中,我有以下几个jars:

代码语言:javascript
复制
saxon9-icu.jar
saxon9-sql.jar
saxon9-stats.jar
saxon9ee-test.jar
saxon9ee.jar
saxon-license.lic

在没有不工作的企业的版本中:

代码语言:javascript
复制
saxon9-dom.jar
saxon9-icu.jar
saxon9-sql.jar
saxon9-stats.jar
saxon9-test.jar
saxon9-xqj.jar
saxon9.jar
saxon9he.jar

我该怎么做才能取代撒克逊缺失的功能呢?这是哪一部分?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-15 09:12:26

DOM代码看上去完全错误,您应该使用名称空间感知的DOM工厂/构建器,然后使用支持名称空间的DOM方法,如createElementNS和setAttributeNS。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34787879

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档