English 中文(简体)
Oracle XSLT:缺省名称空间导致空壳。
原标题:Oracle XSLT: default namespace results in empty tags

我认为,提出这一问题的最佳途径是:我如何为产出的基本内容指明一个缺省名称空间? 这样做:

<xsl:template match="/">
        <r xmlns:s"http://www.mycompany.com/s/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/default/schema" >
....
....

我在Oracle有一处错误:

ORA-31011: XML Parsing Failed
ORA-19201: Error occurred in in XML Processing
LPX-00604: Invalid attribute  nIfNotExist , for attribute  name 
ORA-06512: at SYS.XMLType at line 74 
ORA-06512: at line 24

www.un.org/Depts/DGACM/index_french.htm

 <xsl:template name="nIfNotExist" xmlns:scom="http://www.mycomapny.com/s/schema">
  <xsl:param name="nodeToTest"/>
  <xsl:param name="nodeName"/>
                ...

我希望由此产生的文件能够把这一内容放在这样的考虑上:

<r xmlns:s="http://www.mycompany.com/s/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/default/schema">

我想,http://www.mycompany.com/default/schema>,作为缺省名称空间,文件可以通过SD验证。 否则,在进行验证之前,我不得不人工添加(不是处理批量的办法)。

http://www.ohchr.org。

我已尝试这样做:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:s="http://www.mycompany.com/schema"
 xmlns="http://www.mycompany.com/def_schema">

结果是没有数据的文件,如:

<r xmlns:s="http://www.mycompany.com/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/def_schema">
    <a></a>
    <s:b></s:b>
    <c></c>
    ....

应当:

<r xmlns:s="http://www.mycompany.com/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/def_schema">
    <a>123</a>
    <s:b>ABC34L</s:b>
    <c>7.092381</c>

<>>>>>

来源数据看上去了这样的情况(据我所知,我没有在其中界定的名称空间):

<ROOT_NODE>
    <DATA_A>1234</DATA_A>
    <DATA_B>34567</DATA_B>
    <OTHER_DATA_C>7.123456</OTHER_DATA_C>
</ROOT_NODE>

希望产出

<r xmlns:s="http://www.mycompany.com/schema"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xmlns="http://www.mycompany.com/def_schema">
    <a>1234</a>
    <s:b>34567</s:b>
    <c>7.123456</c>
</r>
最佳回答

有许多可能的解决办法,但从PL/SQL来看,没有任何办法在Oracle很好地发挥作用。 这里的另一家“溶解”发展中国家之一,将XML的物体改装为CLOB,进行一些扼制,将缺省名称空间推入根本内容,然后改换为XML,下一步...... 我不喜欢它,而是工作......

问题回答

www.un.org/Depts/DGACM/index_spanish.htm 这一转变:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:s="http://www.mycompany.com/schema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.mycompany.com/def_schema"
 >
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/*">
  <r>
   <xsl:apply-templates/>
  </r>
 </xsl:template>

 <xsl:template match="DATA_A">
  <a>
   <xsl:apply-templates/>
  </a>
 </xsl:template>

  <xsl:template match="OTHER_DATA_C">
   <c>
    <xsl:apply-templates/>
   </c>
  </xsl:template>

  <xsl:template match="DATA_B">
   <s:b>
    <xsl:apply-templates/>
   </s:b>
  </xsl:template>
</xsl:stylesheet>

在应用XML文件时:

<ROOT_NODE>
    <DATA_A>1234</DATA_A>
    <DATA_B>34567</DATA_B>
    <OTHER_DATA_C>7.123456</OTHER_DATA_C>
</ROOT_NODE>

<>produces of the Hope result:

<r xmlns:s="http://www.mycompany.com/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/def_schema">
    <a>1234</a>
    <s:b>34567</s:b>
    <c>7.123456</c>
</r>

回答是正确的。 当你宣布变革的根基时,你声称(假定你在别处不推翻声明)该文件中的所有非合格内容都属于这一名称空间。 变迁者的每一个非合格要素都将属于这一名称空间。 你们就是这样。

我认为,你也许会忽视的是,在《电离辐射倡议》的转变中,这种名称声明也适用于变革中的XPath模式。 我很幸运的是,你在变革中的XPath node测试与任何投入点相对应,因为投入点位于空洞的空域,而不是你在变革中宣布的名称空间。

你可能希望做的是:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:s="http://www.mycompany.com/schema" 
 xnlns:no=""
 xmlns="http://www.mycompany.com/def_schema">

......然后相应改变变革模式:

<xsl:template match="no:foo">
   <foo>...</foo>
</xsl:template>

这样一来,就存在以下原因之一:<编码>xsl:element——你可以建立一个模板,将各种要素从一个名称空间转变成另一个名称空间,例如:

<xsl:template match="no:*">
   <xsl:element name="{local-name()}">
      <xsl:apply-templates select="node()|@*"/>
   </xsl:element>
</xsl:element>

<><>Edit>:

此前,我一直以这种方式左右着名字空间,而我却指出,上述事实实际上并非合法。 您不能指定名称空间的指定。 因此,你可以把目标名称空间作为你变革的缺省名称空间,因为你无法告诉XPath,以找到来源文件中的内容。

或者,你可以预先确定产出名称空间,例如:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:s="http://www.mycompany.com/schema" 
 xmlns:out="http://www.mycompany.com/def_schema">

......在产出之前写上<>>>>>>>>>>>>>>>>名称空间,该空间赢得任何XML处理器的双向,但可能既有人。 或您可在您的模板中明确指出这一点,例如:

<xsl:template match="foo">
   <xsl:element name="foo" namespace="http://www.mycompany.com/def_schema">
      ...
   </xsl:element>
</xsl:template>




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签