Check-in [12bb39fa7a]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fail in case of a node local namespace, which is not found globally. Before, an identical global prefix (with other namespace) may be picked.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ticket-6fbee320-local-ns-prefix
Files: files | file ages | folders
SHA3-256: 12bb39fa7a3057b8cbb51da555dc674e1deefb41fe721924e29658b3ad2012aa
User & Date: oehhar 2018-11-05 13:41:02
Context
2018-12-06 12:17
(WSDL)Support type with namespace definition in tag. Ticket [6fbee3208e] check-in: a1cf727fd3 user: oehhar tags: trunk
2018-11-05 13:41
Fail in case of a node local namespace, which is not found globally. Before, an identical global prefix (with other namespace) may be picked. Closed-Leaf check-in: 12bb39fa7a user: oehhar tags: ticket-6fbee320-local-ns-prefix
2018-11-05 08:48
Patch to support ns prefix defined in the element. Ticket [6fbee3208e] check-in: 62c4dae5f1 user: oehhar tags: ticket-6fbee320-local-ns-prefix
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Utilities.tcl.

4564
4565
4566
4567
4568
4569
4570

4571
4572
4573
4574
4575



4576

4577
4578
4579
4580

4581

4582
4583
4584

4585
4586
4587

4588












4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
#                                   current node.
#
###########################################################################
proc ::WS::Utils::getQualifiedType {serviceInfo type tns {node {}}} {

    set typePartsList [split $type {:}]
    if {[llength $typePartsList] == 1} {

        set result $tns:$type
    } else {
        lassign $typePartsList tmpTns tmpType
        # Search the namespace attribute in the current node for a node-local prefix.
        # Aim is to translate the node-local prefix to a global namespace prefix.



        # Example is: <xs:element name="A_O_S" type="x1:ArrayOfSomething" xmlns:x1="http://foo.org/bar" />

        # Variable setup:
        # - type: x1:ArrayOfSomething
        # - tmpTns: x1
        # - tmpType: ArrayOfSomething

        # Return value: <Prefix in serviceinfo which corresponds to namespace: "http://foo.org/bar">:ArrayOfSomething

        if {$node ne {}} {
            set attr xmlns:$tmpTns
            if {[$node hasAttribute $attr]} {

                set xmlns [$node getAttribute $attr]
                if {[dict exists $serviceInfo tnsList url $xmlns]} {
                    set result [dict get $serviceInfo tnsList url $xmlns]:$tmpType

                    return $result












                }
                # fail later if namespace not found
            }
        }
        if {[dict exists $serviceInfo tnsList tns $tmpTns]} {
            set result [dict get $serviceInfo tnsList tns $tmpTns]:$tmpType
        } elseif {[dict exists $serviceInfo types $type]} {
            set result $type
        } else {
            ::log::log error $serviceInfo
            ::log::logsubst error {Could not find tns '$tmpTns' in '[dict get $serviceInfo tnsList tns]' for type {$type}}
            set result $tns:$type
            return -code error
        }
    }

    return $result
}

###########################################################################
#
# Private Procedure Header - as this procedure is modified, please be sure
#                            that you update this header block. Thanks.






>





>
>
>
|
>




>
|
>



>



>

>
>
>
>
>
>
>
>
>
>
>
>

<









<
|


<







4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610

4611
4612
4613
4614
4615
4616
4617
4618
4619

4620
4621
4622

4623
4624
4625
4626
4627
4628
4629
#                                   current node.
#
###########################################################################
proc ::WS::Utils::getQualifiedType {serviceInfo type tns {node {}}} {

    set typePartsList [split $type {:}]
    if {[llength $typePartsList] == 1} {
        # No namespace prefix given - use current prefix
        set result $tns:$type
    } else {
        lassign $typePartsList tmpTns tmpType
        # Search the namespace attribute in the current node for a node-local prefix.
        # Aim is to translate the node-local prefix to a global namespace prefix.
        # Example:
        # <xs:element name="A_O_S"
        #    type="x1:ArrayOfSomething"
        #    xmlns:x1="http://foo.org/bar" />
        #
        # Variable setup:
        # - type: x1:ArrayOfSomething
        # - tmpTns: x1
        # - tmpType: ArrayOfSomething
        # Return value:
        #   - <Prefix in serviceinfo which corresponds to namespace: "http://foo.org/bar">
        #   - plus ":ArrayOfSomething"
        if {$node ne {}} {
            set attr xmlns:$tmpTns
            if {[$node hasAttribute $attr]} {
                # There is a node-local attribute (Example: xmlns:x1) giving the node namespace
                set xmlns [$node getAttribute $attr]
                if {[dict exists $serviceInfo tnsList url $xmlns]} {
                    set result [dict get $serviceInfo tnsList url $xmlns]:$tmpType
                    ::log::logsubst debug {Got global qualified type '$result' from node-local qualified namespace '$xmlns'}
                    return $result
                } else {
                    # The node namespace (Ex: http://foo.org/bar) was not found as global prefix.
                    # Thus, the type is refused.
                    # HaO 2018-11-05 Opinion:
                    # Continuing here is IMHO not an option, as the prefix (Ex: x1) might have a
                    # different namespace on the global level which would lead to a misassignment.
                    #
                    # One day, we may support cascading namespace prefixes. Then, we may define
                    # the namespace here
                    set errMsg "Node local namespace URI '$xmlns' not found for type: '$type'"
                    ::log::log error $errMsg
                    return -code error $errMsg
                }

            }
        }
        if {[dict exists $serviceInfo tnsList tns $tmpTns]} {
            set result [dict get $serviceInfo tnsList tns $tmpTns]:$tmpType
        } elseif {[dict exists $serviceInfo types $type]} {
            set result $type
        } else {
            ::log::log error $serviceInfo
            ::log::logsubst error {Could not find tns '$tmpTns' in '[dict get $serviceInfo tnsList tns]' for type {$type}}

            return -code error "Namespace prefix of type '$Type' not found."
        }
    }

    return $result
}

###########################################################################
#
# Private Procedure Header - as this procedure is modified, please be sure
#                            that you update this header block. Thanks.