XML and XSD (Schema) not mapping correctly - sql-server

Hi guys I need your help on this one, I am trying to import and XML generated by SharePoint to a SQL Server Database. I am doing it by SSIS by using an XML Source to ADO.Net Destination
This is how my XML Looks like (I just included 2 items for this sample)
<data z="#RowsetSchema">
<z:row ows_LinkTitle="Lorem ipsum" ows_Description="Dolor sit amet, consectetur adipiscing elit. Phasellus commodo turpis quis diam dapibus volutpat. Proin auctor nulla elit, eu aliquam tellus lacinia non. Vestibulum posuere lectus id metus elementum, eget vulputate est lobortis. Morbi eu enim non lectus aliquet feugiat commodo ac diam. Nunc tempor enim leo. Mauris vitae condimentum erat. Vivamus vitae purus justo." ows_Category="Category 1" ows_Amount="150.000000000000" ows_MetaInfo="1;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Lorem ipsum" ows_ID="1" ows_UniqueId="1;#{32A15E91-0921-496C-8389-B4A861CF63B1}" ows_owshiddenversion="2" ows_FSObjType="1;#0" ows_Created_x0020_Date="1;#2013-11-01 08:59:20" ows_Created="2013-11-01 08:59:20" ows_FileLeafRef="1;#1_.000" ows_PermMask="0x400001f04fff19ff" ows_Modified="2013-11-01 08:59:33" ows_FileRef="1;#sandbox/Lists/Test List/1_.000" xmlns:z="#RowsetSchema" />
<z:row ows_LinkTitle="Maecenas quis" ows_Description="Felis nec nulla aliquam ullamcorper. Sed et suscipit leo. Morbi mauris nibh, feugiat at commodo eget, tincidunt et eros. Vestibulum convallis ipsum vel laoreet venenatis. Quisque mollis elit sed mattis sollicitudin. Maecenas at pretium nulla. Nullam ultricies tempus lorem ut consequat." ows_Category="Category 2" ows_Amount="89.0000000000000" ows_MetaInfo="2;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Maecenas quis" ows_ID="2" ows_UniqueId="2;#{AC2914E0-4101-4493-B301-F27EA6F586C1}" ows_owshiddenversion="2" ows_FSObjType="2;#0" ows_Created_x0020_Date="2;#2013-11-01 08:59:27" ows_Created="2013-11-01 08:59:27" ows_FileLeafRef="2;#2_.000" ows_PermMask="0x400001f04fff19ff" ows_Modified="2013-11-01 08:59:46" ows_FileRef="2;#sandbox/Lists/Test List/2_.000" xmlns:z="#RowsetSchema" />
</data>
and this is how my XSD Looks like
<?xml version="1.0" encoding="Windows-1252"?>
<xs:schema xmlns:tns="#RowsetSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="#RowsetSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="data">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="row">
<xs:complexType>
<xs:attribute name="ows_LinkTitle" type="xs:string" use="required" />
<xs:attribute name="ows_Description" type="xs:string" use="required" />
<xs:attribute name="ows_Category" type="xs:string" use="required" />
<xs:attribute name="ows_Amount" type="xs:decimal" use="required" />
<xs:attribute name="ows_MetaInfo" type="xs:string" use="required" />
<xs:attribute name="ows__ModerationStatus" type="xs:unsignedByte" use="required" />
<xs:attribute name="ows__Level" type="xs:unsignedByte" use="required" />
<xs:attribute name="ows_Title" type="xs:string" use="required" />
<xs:attribute name="ows_ID" type="xs:unsignedByte" use="required" />
<xs:attribute name="ows_UniqueId" type="xs:string" use="required" />
<xs:attribute name="ows_owshiddenversion" type="xs:unsignedByte" use="required" />
<xs:attribute name="ows_FSObjType" type="xs:string" use="required" />
<xs:attribute name="ows_Created_x0020_Date" type="xs:string" use="required" />
<xs:attribute name="ows_Created" type="xs:string" use="required" />
<xs:attribute name="ows_FileLeafRef" type="xs:string" use="required" />
<xs:attribute name="ows_PermMask" type="xs:string" use="required" />
<xs:attribute name="ows_Modified" type="xs:string" use="required" />
<xs:attribute name="ows_FileRef" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Now SSIS recognizes the XSD Correctly as it shows the columns/fields
But that XSD does not map correctly to my XML, what do I need to change on my XSD so it maps correctly? I can also change the XML only to add anything above and below the existing XML.

The <row> element look valid, the only thing that isn't is the existance of the z attribute on your <data> element.
I'd recommend properly declaring the z namespace on the <data> element like so:
<data xmlns:z="#RowsetSchema">
And removing it from any child elements.

Related

xml /XSD file source ssis 2010 - data at root level is invalid to SQL server table

I am trying to learn how to load an XML (XML source) into SSIS 2010 , the data will then go to an SQL Server 2012 Table.
The issue I am having, Is I am trying to follow a tutorial, and I am getting the same error:
The XML Source was unable to read the XML data. Data at the root level is invalid. Line 1, position 1.
This when downloading any of the tables - the one I have chosen is region.
Here is the script - this is in an XSD file
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="countries">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="country">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="iso2Code" type="xs:string" />
<xs:element minOccurs="0" name="name" type="xs:string" />
<xs:element minOccurs="0" name="region">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:string" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="adminregion">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:string" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="incomeLevel">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:string" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="lendingType">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:string" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="capitalCity" type="xs:string" />
<xs:element minOccurs="0" name="longitude" type="xs:string" />
<xs:element minOccurs="0" name="latitude" type="xs:string" />
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="page" type="xs:unsignedByte" use="optional" />
<xs:attribute name="pages" type="xs:unsignedByte" use="optional" />
<xs:attribute name="per_page" type="xs:unsignedByte" use="optional" />
<xs:attribute name="total" type="xs:unsignedByte" use="optional" />
</xs:complexType>
</xs:element>
</xs:schema>
The trail site is http://api.worldbank.org/countries
I have tried changing the top line
<?xml version="1.0" encoding="UTF-8" ?>
with no success. Please help

Bind Content of a UserControl to a Popup inside that UserControl

I am trying to create a UserControl consisting of a button that causes an info popup to show up when clicked. The design and style of the button is defined in the UserControl and will not change, the Content of the Popup should use the Content property of the UserControl itself.
My current approach for the control is:
<UserControl x:Class="InfoPopup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="30" d:DesignWidth="30">
<UserControl.Template>
<ControlTemplate TargetType="UserControl">
<Grid>
<ToggleButton Name="button">
<Label Content="i"/>
</ToggleButton>
<Popup IsOpen="{Binding IsChecked, ElementName=button}" StaysOpen="False">
<ContentPresenter />
</Popup>
</Grid>
</ControlTemplate>
</UserControl.Template>
</UserControl>
And the code where it is used should look like this:
<local:InfoPopup VerticalAlignment="Top" HorizontalAlignment="Right" Height="30" Width="30">
<TextBlock TextWrapping="Wrap" Margin="5" MaxWidth="400">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Cras pulvinar mattis nunc sed. Interdum consectetur libero id faucibus nisl tincidunt eget nullam. Vestibulum rhoncus est pellentesque elit ullamcorper. Enim blandit volutpat maecenas volutpat blandit aliquam etiam erat velit.
<LineBreak />
<LineBreak />
Est sit amet facilisis magna. Quis enim lobortis scelerisque fermentum dui faucibus. Magna eget est lorem ipsum dolor sit amet. Aenean pharetra magna ac placerat vestibulum lectus mauris ultrices. Viverra nam libero justo laoreet sit amet cursus sit. Fermentum posuere urna nec tincidunt praesent. Maecenas volutpat blandit aliquam etiam erat velit scelerisque.
</TextBlock>
</local:InfoPopup>
This causes the popup to show up with the correct size (according to the specified Content) when the button is clicked, but the actual popup content is just (literally) a black box.
What am I missing? I am not very familiar with WPF bindings and templates.
The popup contents are black because the foreground and background are black (by default).
You can either set AllowsTransparency="True" on the Popup (if you want the background to be transparent).
<Popup IsOpen="{Binding IsChecked, ElementName=button}" StaysOpen="False" AllowsTransparency="True">
Or, do something like put a Grid around the ContentPresenter with a background of your choice, like this:
<Grid Background="White">
<ContentPresenter />
</Grid>
If you want the default background color, try this:
<Grid Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
<ContentPresenter />
</Grid>

soapui wsdl empty request

I have tried to generate a wsdl, but when importing it into soap UI the request template is empty - there is no warning or anything else that indicates a problem.
this is the result
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body/>
</soapenv:Envelope>
The wsdl i have made looks like this (removed some for clarity)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://localhost/powershell/" targetNamespace="http://localhost/powershell/" name="powershell">
<wsdl:types>
<xs:schema targetNamespace="http://localhost/powershell/" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="GetProcessRequest">
<xs:complexType name="GetProcessRequestType">
<xs:sequence>
<xs:element name="field1" minOccurs="0" type="xs:string" nillable="false" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetProcessResponse">
<xs:complexType name="GetProcessResponseType">
<xs:sequence>
<xs:element name="o1" minOccurs="0" type="xs:string" nillable="false" />
<xs:element name="o2" minOccurs="0" type="xs:string" nillable="false" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ListGetProcessResponse">
<xs:complexType name="ListGetProcessResponseType">
<xs:complexContent mixed="false">
<xs:restriction base="soapenc:Array">
<xs:attribute ref="soapenc:arrayType" wsdl:arrayType="GetProcessResponseType[]" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="GetItemsRequest">
<xs:complexType name="GetItemsRequestType">
<xs:sequence>
<xs:element name="field1" minOccurs="0" type="xs:string" nillable="false" />
<xs:element name="field2" minOccurs="0" type="xs:string" nillable="false" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetItemsResponse">
<xs:complexType name="GetItemsResponseType">
<xs:sequence>
<xs:element name="o1" minOccurs="0" type="xs:string" nillable="false" />
<xs:element name="o2" minOccurs="0" type="xs:string" nillable="false" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ListGetItemsResponse">
<xs:complexType name="ListGetItemsResponseType">
<xs:complexContent mixed="false">
<xs:restriction base="soapenc:Array">
<xs:attribute ref="soapenc:arrayType" wsdl:arrayType="GetItemsResponseType[]" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:portType name="powershell">
<wsdl:operation name="GetProcess">
<wsdl:input message="tns:GetProcessRequestMessage" />
<wsdl:output message="tns:GetProcessResponseMessage" />
</wsdl:operation>
<wsdl:operation name="GetItems">
<wsdl:input message="tns:GetItemsRequestMessage" />
<wsdl:output message="tns:GetItemsResponseMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="powershellBinding" type="tns:powershell">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetProcess">
<soap:operation soapAction="http://localhost/powershell.svc/GetProcess" style="document">
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</soap:operation>
</wsdl:operation>
<wsdl:operation name="GetItems">
<soap:operation soapAction="http://localhost/powershell.svc/GetItems" style="document">
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</soap:operation>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="powershell">
<wsdl:port binding="tns:powershellBinding" name="powershellBinding">
<soap:address location="http://localhost/powershell.svc" />
</wsdl:port>
</wsdl:service>
<wsdl:message name="GetProcessRequestMessage">
<wsdl:part name="parameters" element="tns:GetProcessRequest" />
</wsdl:message>
<wsdl:message name="GetProcessResponseMessage">
<wsdl:part name="parameters" element="tns:ListGetProcessResponse" />
</wsdl:message>
<wsdl:message name="GetItemsRequestMessage">
<wsdl:part name="parameters" element="tns:GetItemsRequest" />
</wsdl:message>
<wsdl:message name="GetItemsResponseMessage">
<wsdl:part name="parameters" element="tns:GetItemsResponse" />
</wsdl:message>
</wsdl:definitions>
As far as i can tell, everything should be linked correctly, but obviously im missing something somewhere, i just cannot find it.
Your WSDL is not valid. The definition of soap:operation element does not allow any content. You need to close the element soap:operation straight away, without any subelements:
<soap:operation soapAction="http://localhost/powershell.svc/GetItems" style="document" />
You need to do the following change:
<wsdl:operation name="GetItems">
<soap:operation soapAction="http://localhost/powershell.svc/GetItems" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
Similarly for other operations.

Blurry image animation

On application startup, I'd like to do a small animation: a logo should transform from large and blurry to normal and clear. This is what I have so far:
<Grid>
<Border>
<Image Height="250" Name="AnimationLogo" Source="Logo.png">
</Image>
</Border>
<Grid.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Height" Storyboard.TargetName="AnimationLogo">
<LinearDoubleKeyFrame Value="50" KeyTime="0:0:5.0"></LinearDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
I know that I can animate a static blurry like this:
<Image.Effect>
<BlurEffect Radius="20"/>
</Image.Effect>
But I could not manage to animate this BlurEffect on the image. There is no Property "Radius" on the image that I could use in the animation.
I'd be thankful for a hint or a good link!
You can try naming the BlurEffect
<Image.Effect>
<BlurEffect Radius="20" x:Name="blurEffect"/>
</Image.Effect>
And animation for TargetName blurEffect
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Radius"
Storyboard.TargetName="blurEffect">
<LinearDoubleKeyFrame Value="50" KeyTime="0:0:5.0"></LinearDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
It is possible to Animate Blur on Loaded event usig the WPF Transitionz library.
A simple code example:
<Window x:Class="WpfApplication15.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tz="http://schemas.abtsoftware.co.uk/transitionz"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525"
WindowStartupLocation="CenterScreen">
<Grid>
<TextBlock Foreground="#AAA" Margin="10" TextWrapping="Wrap" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec, blandit vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices ultrices enim. Curabitur sit amet mauris. Morbi in dui quis est pulvinar ullamcorper. "
tz:Transitionz.Opacity="{tz:OpacityParams Duration=2000, From=0, To=1, TransitionOn=Loaded}"
tz:Transitionz.Blur="{tz:BlurParams Duration=2000, From=20, To=0, TransitionOn=Loaded}"/>
</Grid>
</Window>
Which results in this animation on loaded of the window.
It is also possible to animate blur on property changed by binding the tz:Transitions.Blur to a Property of type BlurParams in the ViewModel.

How do I reference the Toggle Button Circle and override vertical alignment of the Aero theme Expander?

Currently, I am referencing the Aero theme in my App.xml file.
In the main.xml file, I am using expanders to display the content in a resizable width app.
(For this example, I limited the width to 500)
The expander header content generally will be short, but it allows for up to 500 chars.
Depending on the window size (600 pixels by default), the content can wrap (thereby stretching the expander header downwards).
This is fine, but the toggle button (a circle /w arrow) is set for VerticalAlignment=center from what I can tell.
I need a way to override that VerticalAlignment in a style without re-creating the Aero template for the Expander.
I just cant seem to reference the circle and arrow objects.
I have tried overriding Toggle Button as well, with no luck.
As you can see below, I can override some aspects of the Aero Expander.
I just need that little nudge to get the Toggle Button Circle and Arrow objects to change the VerticalAlignment.
Thanks
Code example follows:
<Window.Resources>
<Style TargetType="{x:Type Expander}" BasedOn="{StaticResource {x:Type Expander}}">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#464646" />
<Setter Property="Width" Value="Auto" />
<Setter Property="Margin" Value="1,0,1,0" />
<Setter Property="IsExpanded" Value="False" />
</Style>
</Window.Resources>
<Expander ContextMenu="{StaticResource cMnu}" Width="auto">
<Expander.Header>
<StackPanel Orientation="Horizontal" Width="auto" Margin="0">
<TextBlock Width="65">Normal</TextBlock>
<TextBlock Width="80">Open</TextBlock>
<TextBlock Width="80">10/31/2009</TextBlock>
<TextBlock TextWrapping="Wrap" Width="500">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aliquam ultrices auctor magna, sit amet commodo ipsum accumsan eu.
Sed a mollis felis. Nam ullamcorper augue vel mauris consequat imperdiet.
Nunc in augue mauris.
Quisque metus tortor, porttitor nec auctor id, mollis nec ipsum.
Suspendisse eget ipsum vitae lectus fermentum porta.
Aliquam erat volutpat.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Phasellus congue dui ac arcu eleifend a amet.
</TextBlock>
</StackPanel>
</Expander.Header>
</Expander>
If you look at the default template for the Expander, you can see why none of your property setters are working:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ToggleButton IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,
RelativeSource={RelativeSource TemplatedParent}}"
OverridesDefaultStyle="True"
Template="{StaticResource ExpanderToggleButton}"
Background="{StaticResource NormalBrush}" />
<ContentPresenter Grid.Column="1"
Margin="4"
ContentSource="Header"
RecognizesAccessKey="True" />
</Grid>
The ToggleButton's VerticalAlignment is what you are after, and there are no setters for it.
It seems to me that there is no way to change this alignment property through the Style. You must provide a new template.

Resources