Static Type doesn't allow axis movement?

Hi all, hoping someone can help me here. I have a problem, found a solution but I don't really understand it - hoping someone can explain and help me make sure I'm really solving this in the best way (or if there is a better way)
I'm trying to use value() on a parent item and I get the error
XQuery [value()]: Cannot implicitly atomize or apply 'fn:data()' to complex content elements, found type 'xs:anyType' within inferred type 'element(at{http://blah/log/Action_Touch.xsd}:Id,xs:anyType) ?'.
My repro code is below 
CREATE XML SCHEMA COLLECTION dbo.[Action_Touch]
AS N'<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="Action_Touch"
targetNamespace="http://blah/log/Action_Touch.xsd"
elementFormDefault="qualified"
xmlns="http://blah/log/Action_Touch.xsd"
xmlns:mstns="http://blah/log/Action_Touch.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:element name="Action_Touch">
<xs:complexType>
<xs:sequence>
<xs:element name="Action" type="mstns:Action"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="Action">
<xs:sequence>
<xs:element name="Id" type="xs:int" minOccurs="1" maxOccurs="1"/>
<xs:element name="ActionItem" type="mstns:ActionItem" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ActionItem">
<xs:sequence>
<xs:element name="Id" type="xs:int" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
GO
create procedure dbo.test
as
declare @_Action_Touch_Xml xml (document dbo.Action_Touch)
select @_Action_Touch_Xml = N'<?xml version="1.0" encoding="utf-16"?>
<at:Action_Touch xmlns:at="http://blah/log/Action_Touch.xsd">
<at:Action>
<at:Id>15</at:Id>
<at:ActionItem>
<at:Ordinal>1</at:Ordinal>
<at:Id>28</at:Id>
</at:ActionItem>
</at:Action>
</at:Action_Touch>'
;with xmlnamespaces('http://blah/log/Action_Touch.xsd' as at
select
ai.c.value('at:Id[1]' , 'int') as Id
, ai.c.value('../at:Id[1]' , 'int') as Action_Id
from @_Action_Touch_Xml.nodes('/at:Action_Touch/at:Action/at:ActionItem') ai(c)
go
If I replace the parent referencing line with
, ai.c.value('string(../at:Id[1])' , 'int') as Action_Id
Then it is ok, but is there no better way? This seems like a hacky work around to me..
Appreciate any pointers on this. Thanks

Generally I avoid parent-axis (..) due to severe performance problems particularly with larger pieces of xml.  This is described in detail
here.
As is happens, parent-axis also has an issue around inferring xs:anyType, which is described in this MSDN article,
XQuery and Static Typing:
"Some operations lose type information during inference. For example, if the type of a node cannot be determined, it becomes anyType. This is not implicitly cast to any other type. These conversions occur most notably during navigation by using the parent
axis. You should avoid using such operations and rewrite the query, if the expression will create a static type error."
The solution is to rewrite the query, using CROSS|OUTER apply to drill into the xml left to right, eg
;WITH XMLNAMESPACES('http://blah/log/Action_Touch.xsd' AS at )
SELECT
ai.c.value('at:Id[1]', 'INT') AS ActionItem_Id
, a.c.value('at:Id[1]', 'INT') AS Action_Id
FROM @_Action_Touch_Xml.nodes('/at:Action_Touch/at:Action') a(c)
CROSS APPLY a.c.nodes('at:ActionItem') ai(c)

Similar Messages

  • IOException: Incorrect stream type, doesn't allow push back of bytes

    Hi,
    We are trying to develop a java program that is supposed to open an SSL connection to an external trading partner and send some xml data. We are using the http_client.jar (HTTPClient) library to do that. We have already managed to write a program to do SSL requests but we also need to pass these requests through a proxy server. When we use this proxy server we get the following exception from HTTPClient:
    Exception in thread "main" java.io.IOException: Incorrect stream type, doesn't allow push back of bytes
    at HTTPClient.Response.readLines(Response.java(Compiled Code))
    at HTTPClient.Response.readResponseHeaders(Response.java:1030)
    at HTTPClient.Response.getHeaders(Response.java:713)
    at HTTPClient.Response.getStatusCode(Response.java:262)
    at HTTPClient.HTTPConnection.enableSSLTunneling(HTTPConnection.java:3335)
    at HTTPClient.HTTPConnection.doConnect(HTTPConnection.java:4027)
    at HTTPClient.HTTPConnection.connect(HTTPConnection.java:4004)
    at SSLRequest.main(SSLRequest.java:22)
    Out program source code is:
    public class SSLRequest
         public static void main(String[] args) throws Exception
              HTTPConnection httpsConnection = new HTTPConnection("https", "www.verisign.com", 443);
              httpsConnection.setCurrentProxy("myproxy.mydomain.gr", 8080);
              httpsConnection.setAllowUserInteraction(false);
              httpsConnection.connect();
              HTTPResponse rsp = httpsConnection.Get("/");
              System.out.println(rsp);
    We would really appreciate any help on this
    Thanks.

    Hi,
    I found out that this is a reported bug (bug no. 3748882) that applies with App Server version 9.0.4 which is using SSL via a proxy server. The solution is to upgrade to app server version 10.1.2
    Patrick.

  • ITunes doesn't allow me to watch a movie

    I rented a movie and after downloading it iTunes doesn't allow me to watch it, it says that needs the authorization of iTunes and that iTunes must be open... but its already open and nothing happens.
    Solved. I just waited 15 min and tried again

    are you getting a specific error number?
    Update and restore alert messages on iPhone, iPad, iPod touch and Apple TV (2nd generation)
    http://support.apple.com/kb/TS1275

  • HT1304 My movies are in a mp4 format and it doesn't allow me to import them into itunes

    I have an iPad 3 and my movies are all in a mp4 format and the movies are saved on desktop. I'm trying to import my movies into the section which says "films" and it doesn't allow me to do so. How can I import these movies onto my iPad???

    i have the same problem since updating to mountain lion, ***?

  • WM movement type 255 not allowed for warehouse number 008

    Hi,
    Error message "WM movement type 255 not allowed for warehouse number 008" pops up during creation of outbound delivery. I checked the schedule line for this sales order, it was actually tagged to movement type 631 instead of 255. There ain't any movement type 255 at all. How to solve this?
    Thanks.

    Hi,
    Check in Customizing for Define Movement Types where for the given warehouse number movement type 255 is assigned.
    Path is,
    Logistics Execution - Activities - Transfers - Define Movement Types.
    Check for 008 Movement 255 is assigned or not.
    Thanks
    Krishna.

  • New iTunes on Mac doesn't allow me anymore to select all songs and 'Get info' to adjust the volume, like the old one. It says"your selection contains more than one type of media". They are all songs! Help please!

    New iTunes on Mac doesn't allow me anymore to select all songs and 'Get info' to adjust the volume, like the old one. It says"your selection contains more than one type of media". They are all songs! Help please!

    Raya Alfa wrote:
    ...there are some that are mp3 and it will be extremely hard to pick them from the lot.
    Not true. Select "Kind" as a sort category by right clicking the headings
    Then click to sort by Kind
    If your Import Settings are for Apple Lossless, AIFF, AAC or whatever the majority of your files are, convert MP3s to that file type.
    I've presently got 17,000+ files in my library, and they're ALL MP3 or M4B(Audiobooks). If they weren't when I got them, I converted them.  Saves a LOT of hassels with just this type of situation. Besides I have two non Apple MP3 players that WON'T work with other file types besides MP3 so, EVERYTHING I have has to be MP3.

  • I have CS6 in a disk and I can't install it,I get a window with my name and asking for a pass word,the window reads like this:set up wants to make changes type PW to allow this.I type my adobe PW and it doesn't work.I am stake in that step.

    What can I do?I can't install CS6 in a disk.I get a window reading:set up wants to make changes type PW to allow this.
    Type my Adobe PW and is not that.This is frustrating!!!!Downloading, Installing, Setting Up

    Hello ozne,
    as a first step please have a look at these "General infos about the Adobe Account"
    https://www.adobe.com/account.html and http://helpx.adobe.com/x-productkb/global/find-serial-number.html.
    Did you purchase your product from these firms like Amazon? If yes, this is not a serial number, only a code with which you can request a serial number from Adobe. Please have a look at http://helpx.adobe.com/x-productkb/global/find-serial-number.html. (Start here: How did you purchase your product?)
    The following part, so I just see at least, ceased to exist on my Adobe website, everything takes place in the link from above. I leave it as an info yet, it might still fit for you. For this purpose, please click your way through to your Adobe Store and find the button "Get Serial Number". Fill in the form and after a while you will get the real serial number.
    Good luck!
    Hans-Günter

  • Static Type Parameters

    Hi,
    Consider the following example code:
    public class Test<E>{
      E e1;  //this is fine
      static E e2;  //this is not fine
    }I know the JLS version 3 makes it clear that static type parameter declarations are forbidden, but what is the technical reason for this? It is more than simply type erasure, in which case you would have to say that we create "static Object e2," which is of course permitted.

    OK, perhaps I failed to get my thoughts fully across.
    What I am suggesting is that Test<String> and
    d Test<Integer> be completely disjoint types.There is a difference between classes and types.
    Generic types are not templates ;-)
    type erasure and compatibility are some of
    the answers to that.The answer is compatibility and design. Types
    and classes are not the same. Static variables are class
    variables, not type variables (sorry, this is overloading).
    Erasure is an implementation technique and can't
    support your suggestion. However, if a different
    implementation technique had allowed it, I would
    still vote no :-)
    In any case, I'm just pointing out one case in
    generics where static doesn't fly.I don't understand. static works fine. Type variables
    aren't available in static context, but niether are instance
    variables. Type variables are related to instances.
    Do you assume that in order to reify types (aka having
    type arguments at runtime) the implementation must
    share similar type arguments. However, a perfectly
    fine solution to reification (if you scrap compatibility)
    would be to synthesize a new field on all instances of
    generic classes, like this:
    class Foo<T> {
        private final Type actualTypeArgument$T; // synthetic, added by compiler
    }This is not efficient, but that doesn't mean
    that there should be observable differences from this
    technique to a technique that uses more sharing.
    Even if you say
    there shouldn't be statics, you have to admit that
    there are new restrictions because of them, no?What new restrictions? Type variables are non-static
    and so can't be used in a static context, this isn't a
    new concept.
    I'm
    just saying the simplicity of Java is becoming
    slightly more complicated.I disagree, I think your proposal would make Java
    more complicated. I think most people would be surprised
    to see different values of static field based on type arguments.
    Also, this would mean that static initializers would be
    executed multiple times. I say nay ;-)

  • Migration Assistant doesn't allow me to choose what drive.

    Well, I got my new computer. I tried to migrate a drive from my old computer using Migration Assistant. and it doesn't allow me to choose what drive.
    In my old computer I have 5 drives. The original HD (was 10GB, was replaced last year by a 40 GB) and on my Hitachi 250 GB drive that I added 2 years ago, there's a partition with 4 drives.
    I wanted to migrate one particular drive from there (called Current work).
    First I did a mistake. I connected both computer via the firewire in the afternoon when there was enough daylight so I don't have to do it later at night (the computers are under the table.) I thought it's OK since I'm not pushing any button yet ("migrate now", "transfer", and such).
    I turned on the new computer and a message appeared: you must restart.
    That's strange, I said to myself. it's a brand new computer. Usually It says that when there's a problem, but OK I restart and when it's back on, I see that my external drive (Neptune from OWC which was still hooked up in the old computer) is on the desktop. And it took just a few seconds. I open it and all the files, etc. are there. It did copy the whole external drive !
    I'm not an computer expert but I believe the Mac Pro did notice that's there's a firewire hooked up and then, without asking me, migrated the external drive and that's why it asked me to restart. I would have prefer if it tells me "restart so migration can begin".
    I don't mind for now that my external drive is on my new computer. I can always erase it if I don't want it. It is still external right ? so it doesn't intrude on the 640 GB of my HD so I just keep it.
    But it also copied/migrate Mac HD 40 GB which is full of OS 9 and I almost never use it anymore. I don't want it coz it has applications and they advise not to migrate applications (certainly not applications with issues).
    They say migrate folders, settings but re-install applications.
    And it migrated also another drive called "Scratch" which has only personal date no system, no software.
    Anyway, I erased everything and re-installed using the Install disk that came with the computer.
    BTW, what they say in the manual (p. 90: Re-installing the software that came with your Mac Pro) is different than what really happens.
    They say insert disk, double- click on Install and then click options in the "Select a destination" pane of the installer. Then click "erase and install" Problem is: there's no "Select a destination" pane. Or any options.
    I had to go to Disk utility and erase, then re-install OS X.
    Then re-install the applications using "Install applications" (the other disc that came with the computer. )
    OK, I did that. Then while everything is empty, new, I used Migration Assistant.
    Now here is the reason why I post this.
    They say hold T key until you see a firewire icon then select a drive. I can't see when there's an icon coz I have only one monitor, so I just hold and hold the T-key and turn on the old computer. The screen shows "waiting for you other computer to restart" 2 min.... 5 min... 7 min. Nothing happens. I stop holding.
    I look at the desktop and I see that the icon of the old 40 GIG Mac HD is there. (and I believe with a firewire logo, but not sure about that.)
    I have the impression that if I kept the T-key longer it would have migrate the other drives as well.
    They say keep the T-key down until you see the firewire (then let go I suppose. As I said I don't see what's going on on the desktop of my old computer so I kept the T-key for a few minutes. I also tried another time to let go after 1-2 min. No difference.
    I shut down the new comp. and the old computer screen appears automatically (both are connected to the monitor; the old with analog port, the new with digital port) and sure enough the firewire icon is moving on the screen.
    I go back to the new computer and put the old 40 GIG Mac HD in the trash. Actually, when it touched the trash, I just saw an eject icon and the drive disappear. Did not go in the trash which is empty. So I guess I ejected, not sure what's the difference but I looked for it to see if it's anywhere in the computer. Could not find it. Not in the HD, not in the desktop. Good, I don't want it there. Is it hidden somewhere ?
    So I tried again but wondering perhaps the old computer should RESTART not turn on (it was off) so now I wait until it's on, then push restart. I hear the gong when it shuts off but that's it, no other gong when it comes back. I keep the T-key. But nothing happened. Just see the message "waiting for your other computer to restart"
    PS: BTW Target mode (which seems to me similar to Migrating with "Migration Assistant") will not work for me because it must be SATA, mine is ATA.
    I didn't try but read that it has to be SATA.
    Is it the same ? In migrating they say hold down the T-key (T for target)
    And how come that my 40GB HD which is ATA did migrate (not that I wanted too but still).
    Also, this drive ("Current Work") that I want to migrate to the new computer is in my external drive. Can't I just drag it ? If it has only personal data, files and folders I know I can, but It has system (OS X) and applications. It's the one I use and boot on, in my old G4 but I want to transfer Files and folders and settings, so the new computer will know what are my Safari preferences, Automatic fill-in, and perhaps it will move my iTunes music Library too ?
    Basically everything except applications. Although I would like my Nikon scanner to be in the new computer as well as the LaCie DVD recorder but I guess I can do that later, separately ?
    What are the settings or info I need ? Because if it's just Safari preferences, automatic fill-in and other such small thing, it might be better to just do it again in the new comp and forget about the hassle of migrating.

    Try getting into Windows and then plugging in the Superdrive. The drive will only be attached to one OS or the other, not both.

  • Lion mail doesn't allow shortcuts for bold and italics.

    Hi,
    I've come across this problem in which Lion mail doesn't allow shortcuts for bold and italics. I try pressing the short cut for Command + B or Command + I
    but it does not affect the text at all. I have to move my cursor to the Bold or Italic icon to change a particular word's form.
    Of note, Command + U allows me to underline a word just fine. I also write my mail in the default Helvetica, and in size 12.
    Anyone know of a solution? I'm pretty sure it's just a glitch, but it's become a great annoyance for me.
    Thanks for your help!

    Hi,
    I've come across this problem in which Lion mail doesn't allow shortcuts for bold and italics. I try pressing the short cut for Command + B or Command + I
    but it does not affect the text at all. I have to move my cursor to the Bold or Italic icon to change a particular word's form.
    Of note, Command + U allows me to underline a word just fine. I also write my mail in the default Helvetica, and in size 12.
    Anyone know of a solution? I'm pretty sure it's just a glitch, but it's become a great annoyance for me.
    Thanks for your help!

  • The search suggestion drop box doesn't allow you to go on the web when you click on the suggestion.

    When I type in a search word in the search box, the dropdown menu of suggestions doesn't allow access onto the web.

    Try Enter Selects: https://addons.mozilla.org/en-US/firefox/addon/7423/
    You can just start typing in the Location Bar, and press Enter to go straight to the first match.
    '''Other issues:'''
    Your are running an out of date Firefox that is potentially vulnerable to malware. Please consider upgrading using Tools -> Check For Updates or downloading and installing from http://www.mozilla.com/en-US/firefox/all-older.html
    Your plugins are out of date and also potentially vulnerable to attacks from malicious web sites. Consider getting them all updated with Plugin Check: http://www.mozilla.com/en-US/plugincheck/

  • Not Allowing Goods Movements for the confirmed quantity in the delivery

    Hi Gurus,
    I would like know how to make the system not allowing movement for a batch at MB11  when that batch of one material is confirmed in a delivery? 
    ex: In the delivery: material number: 9009, Batch  0000A and quantity is 10. And there is no more quantitty in the warehouse for Batch 000A and material number: 9009.
    Dont allow any movement type for 9009 and 000A batch.
    Thanks a lot

    Hi,
    As far as my understanding there is no such provision,
    Check is there any option to block assigned batch temporarily, so system can not consider it for next business transaction
    Kapil

  • The new Keynote 6.0 doesn't allow me to insert a .avi

    The new Keynote 6.0 doesn't allow me to insert a .avi movie while version 5.3 does. Is this a bug or how can I get around it?

    I found the answer to the problem in another discussion. I don't know why I have to turn on the calendar at Icloud for the calendar to work.
    What if I didn't have an Icloud account?  It doesn't make sense...
    The user guide is not clear on this matter it says you have to subscribe to a calendar and that your calendar will be blocked if you subscribe, but it's the opposite... I

  • Autofill file doesn't allow editing or deleting

    In Safari on my iMac 5 autofill doesn't allow removal of any user names or passwords. Safari has problems and I think this file is corrupt.
    Can the file be deleted so it can be created again through Safari?

    Passwords are stored in Keychain Access   /Applications/Utilities
    And from the Safari menu bar click Safari / Preferences - Auofill
    Click the Edit button to the right of: User names and passwords
    Make selections(s) then click Remove.
    If you still can't remove user names and passwords from the Autofill pane, try troubleshooting the Safari. plist file.  (preferences)
    Go to ~/Library/Preferences. Move the com.apple.Safari.plist file to the Desktop.
    Quit then relaunch Safari to test. If that helped, move the .plist file to the Trash.
    ~ (Tilde) character represents your Home folder.
    If that didn't help, quit Safari. Open a Finder window select your Home folder in the Sidebar on the left. Then open the Library folder, then the Caches folder, then the com.apple.Safari folder. Move the cache.db (or ApplicationCache.db) file from the com.apple.Safari folder to the Trash. Relaunch Safari.

  • I was attempting to burn a dvd from iMovie but after several attempts could not. Contacted tech support and they say lion iMovie doesn't support burning movies. What a rip (excuse the pun). What do I do now?

    Imovie in os10 lion doesn't allow you to burn dvds. How do I do it then?

    iMovie has never been able to burn DVDs.
    It's iDVD that burns DVDs.
    Currently the only place to get iDVD is if you buy a boxed version of iLife 09 which you can still find at places like Amazon.
    There are also alternatives to iDVD.  You can read about some of them here:
    http://www.tuaw.com/2010/10/28/after-ilife-11-alternatives-to-idvd-and-iweb/
    Depending on your movies size, it may also be possible to create a QuckTime version of it and burn that to a data DVD that others can play back on their comptuers.
    Matt

Maybe you are looking for

  • Linking multiple emails to a single event in ical and/or to do's

    Hi: Often I receive emails and I want to link them to an event in ical. OS X does this just fine as long as there is date in the email that OS X can recognize. The problem is sometimes I get multiple emails relating to the same event and I would like

  • SM:SELFDIAGNOSIS background job getting failed in Solution manager

    Hi All, SM:SELFDIAGNOSIS background job getting failed in Solution manger server : Job Log: 2-22-2012 16:44:02 Job started                                                                                00           516          S 2-22-2012 16:44:02 S

  • I can see only one Printer with Apple Talk, but there are five ???

    I have a problem on only one mac, with the Apple Talk. We have over 100 Macintosh and all the other machines see the five printers. But this one can only see "one" printer??? What is this? We change the switch port but nothing. Can i delete any chach

  • Removing black bars from youtube/altering aspect ratios for youtube

    How do you get rid of the black lines on the vid on youtube using I Movie 08? I have tried using the crop options in I movie, and still cant get rid of the back lines above and below. The cameras aspect ratio is 4:3 and using crop options of "fit" or

  • French accent marks in Pages

    I'm having trouble inserting French accent marks into my text. I've gone through the Help list but there does not appear to be an OPTION on my screen. Is there a simple way of doing this?