XSD if-else条件

时间:2016-11-23 11:56:16

标签: xml xsd schema

我需要在我的xsd架构中创建if / else条件。特别是模式节点。我怎么能这样做?

import heapq
import socket

class HuffmanEncoder:
    output = {};
    class Node:
        def __init__(self,data,freq,left=None,right=None):
            self.data = data
            self.freq = freq
            self.left = left
            self.right = right

    def __init__(self,root):
        self.root = root

    def isLeaf(root):
        return not root.left and not root.right

    def buildHuffman(p):
        while len(p) != 1:
            left = heapq.heappop(p)[1]
            right = heapq.heappop(p)[1]
            top = HuffmanEncoder.Node('$',left.freq + right.freq)
            top.left = left
            top.right = right
            heapq.heappush(p,(top.freq,top))
        return heapq.heappop(p)[1]

    def printCodes(root,arr,top):
        if root.left:
            arr.insert(top,'0')
            HuffmanEncoder.printCodes(root.left,arr,top + 1)

        if root.right:
            arr.insert(top,'1')
            HuffmanEncoder.printCodes(root.right,arr,top + 1)

        if HuffmanEncoder.isLeaf(root):
            s = ""
            for i in range(0,top):
                s += arr[i]
            HuffmanEncoder.output[root.data] = s
        return HuffmanEncoder.output

def main():
    p = []
    arr = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ']
    freq = [8.167,1.492,2.782,4.253,12.702,2.228,2.015,6.094,6.966,0.153,0.772,4.025,2.406,6.749,7.507,1.929,0.095,5.987,6.327,9.056,2.758,0.978,2.360,0.150,1.974,0.074,25.422]
    for i in range(0,len(arr)):
        x = HuffmanEncoder.Node(arr[i],freq[i])
        heapq.heappush(p,(x.freq,x))

    root = HuffmanEncoder.buildHuffman(p)
    arr = []
    top = 0
    codes = HuffmanEncoder.printCodes(root,arr,top)
    for key in sorted(codes):
        print(key,codes[key])
    s = input()
    for i in range(0,len(s)):
        print(codes[s[i]])

if __name__ == '__main__':
                 main()

1 个答案:

答案 0 :(得分:5)

不,您无法在select a.*,table_2_col_1, table_2_col_2 from (select table_1_col_1, table_1_col_2 from table_1 where ) a, table_2 where table_1_col_1 like '%' || table_2_col_1 ||'%' 中使用if

不,您无法在xs:pattern/@value中引用其他元素。

你能做什么:

  • XSD 1.0 :重构您的XML设计并使用核心内容建模 构建体。
  • XSD 1.1 :条件类型分配可能有所帮助。
  • XSD 1.1 :断言可能会有所帮助。

更具体的指导可能只有一个更具体的问题才能显示应该和不应该有效的XML,这解释了xs:pattern/@value等。