Showing posts with label schema. Show all posts
Showing posts with label schema. Show all posts

Friday, March 23, 2012

Problem with inline validation

Hi,
i have this file:
<?xml version="1.0"?>
<catalog xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- START OF SCHEMA -->
<xsd:schema>
<xsd:element name="book">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="author" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="genre" type="xsd:string"/>
<xsd:element name="price" type="xsd:float"/>
<xsd:element name="publish_date" type="xsd:date"/>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<!-- END OF SCHEMA -->
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<cost>44.95</cost>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with
XML.</description>
</book>
</catalog>
it's an microsoft example.
Why when i try to validate this file the object return me that the file
is valid?!
(there is a <cost> element that is not declared in xsd schema).
Anybody knows why?
I've used this script to validate:
<%
' Validate files and display output in text box.
Dim sOutput
sOutput = ValidateFile("novalid.xml")
response.write sOutput
Function ValidateFile(strFile)
Path = "C:\inetpub\cmssviluppo1\wwwroot\sviluppo\esempi2"
' Create an XML DOMDocument object.
set x = CreateObject("MSXML2.DOMDocument.6.0")
' Load and validate the specified file into the DOM.
x.async = False
x.validateOnParse = True
x.resolveExternals = True
x.Load Path & "\" & strFile
' Return validation results in message to the user.
If x.parseError.errorCode <> 0 Then
ValidateFile = "Validation failed on " & _
strFile & vbCrLf & _
"=====================" & vbCrLf & _
"Reason: " & x.parseError.reason & _
vbCrLf & "Source: " & _
x.parseError.srcText & _
vbCrLf & "Line: " & _
x.parseError.Line & vbCrLf
Else
ValidateFile = "Validation succeeded for " & _
strFile & vbCrLf & _
"======================" & _
vbCrLf & x.xml & vbCrLf
End If
End Function
%>
Thanks!!
Processing of inline schemas is off by default in MSXML6. You need to set
UseInlineSchema property to true:
x.validateOnParse = True
x.resolveExternals = True
x.useInlineSchema = True
More info on msdn:
http://msdn.microsoft.com/library/de...3695c318bf.asp
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"maurox" <mrago@.inwind.it> wrote in message
news:1140540428.842442.100810@.f14g2000cwb.googlegr oups.com...
> Hi,
> i have this file:
> <?xml version="1.0"?>
> <catalog xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <!-- START OF SCHEMA -->
> <xsd:schema>
> <xsd:element name="book">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="author" type="xsd:string"/>
> <xsd:element name="title" type="xsd:string"/>
> <xsd:element name="genre" type="xsd:string"/>
> <xsd:element name="price" type="xsd:float"/>
> <xsd:element name="publish_date" type="xsd:date"/>
> <xsd:element name="description" type="xsd:string"/>
> </xsd:sequence>
> <xsd:attribute name="id" type="xsd:string"/>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
> <!-- END OF SCHEMA -->
> <book id="bk101">
> <author>Gambardella, Matthew</author>
> <title>XML Developer's Guide</title>
> <genre>Computer</genre>
> <cost>44.95</cost>
> <publish_date>2000-10-01</publish_date>
> <description>An in-depth look at creating applications with
> XML.</description>
> </book>
> </catalog>
> it's an microsoft example.
> Why when i try to validate this file the object return me that the file
> is valid?!
> (there is a <cost> element that is not declared in xsd schema).
> Anybody knows why?
> I've used this script to validate:
> <%
> ' Validate files and display output in text box.
> Dim sOutput
> sOutput = ValidateFile("novalid.xml")
> response.write sOutput
> Function ValidateFile(strFile)
> Path = "C:\inetpub\cmssviluppo1\wwwroot\sviluppo\esempi2"
> ' Create an XML DOMDocument object.
> set x = CreateObject("MSXML2.DOMDocument.6.0")
> ' Load and validate the specified file into the DOM.
> x.async = False
> x.validateOnParse = True
> x.resolveExternals = True
> x.Load Path & "\" & strFile
> ' Return validation results in message to the user.
> If x.parseError.errorCode <> 0 Then
> ValidateFile = "Validation failed on " & _
> strFile & vbCrLf & _
> "=====================" & vbCrLf & _
> "Reason: " & x.parseError.reason & _
> vbCrLf & "Source: " & _
> x.parseError.srcText & _
> vbCrLf & "Line: " & _
> x.parseError.Line & vbCrLf
> Else
> ValidateFile = "Validation succeeded for " & _
> strFile & vbCrLf & _
> "======================" & _
> vbCrLf & x.xml & vbCrLf
> End If
> End Function
> %>
> Thanks!!
>
|||ok, i do this but the page return me that the property is no supported
by object...
i use vbscript in asp page.
maybe i can't validate a file with an inline schema by vbscript?
|||anybody can help me?
|||ok, i have fix the problem.
UseInlineSchema is a second-level property. to set it true is necessary
type this:
x.setProperty "UseInlineSchema", true
http://windowssdk.msdn.microsoft.com...3695c318bf.asp
thank

Problem with inline validation

Hi,
i have this file:
<?xml version="1.0"?>
<catalog xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- START OF SCHEMA -->
<xsd:schema>
<xsd:element name="book">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="author" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="genre" type="xsd:string"/>
<xsd:element name="price" type="xsd:float"/>
<xsd:element name="publish_date" type="xsd:date"/>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<!-- END OF SCHEMA -->
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<cost>44.95</cost>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with
XML.</description>
</book>
</catalog>
it's an microsoft example.
Why when i try to validate this file the object return me that the file
is valid?!
(there is a <cost> element that is not declared in xsd schema).
Anybody knows why'
I've used this script to validate:
<%
' Validate files and display output in text box.
Dim sOutput
sOutput = ValidateFile("novalid.xml")
response.write sOutput
Function ValidateFile(strFile)
Path = " C:\inetpub\cmssviluppo1\wwwroot\sviluppo
\esempi2"
' Create an XML DOMDocument object.
set x = CreateObject("MSXML2.DOMDocument.6.0")
' Load and validate the specified file into the DOM.
x.async = False
x.validateOnParse = True
x.resolveExternals = True
x.Load Path & "\" & strFile
' Return validation results in message to the user.
If x.parseError.errorCode <> 0 Then
ValidateFile = "Validation failed on " & _
strFile & vbCrLf & _
"=====================" & vbCrLf & _
"Reason: " & x.parseError.reason & _
vbCrLf & "Source: " & _
x.parseError.srcText & _
vbCrLf & "Line: " & _
x.parseError.Line & vbCrLf
Else
ValidateFile = "Validation succeeded for " & _
strFile & vbCrLf & _
"======================" & _
vbCrLf & x.xml & vbCrLf
End If
End Function
%>
Thanks!!Processing of inline schemas is off by default in MSXML6. You need to set
UseInlineSchema property to true:
x.validateOnParse = True
x.resolveExternals = True
x.useInlineSchema = True
More info on msdn:
http://msdn.microsoft.com/library/d...e3695c318bf.asp
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"maurox" <mrago@.inwind.it> wrote in message
news:1140540428.842442.100810@.f14g2000cwb.googlegroups.com...
> Hi,
> i have this file:
> <?xml version="1.0"?>
> <catalog xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <!-- START OF SCHEMA -->
> <xsd:schema>
> <xsd:element name="book">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="author" type="xsd:string"/>
> <xsd:element name="title" type="xsd:string"/>
> <xsd:element name="genre" type="xsd:string"/>
> <xsd:element name="price" type="xsd:float"/>
> <xsd:element name="publish_date" type="xsd:date"/>
> <xsd:element name="description" type="xsd:string"/>
> </xsd:sequence>
> <xsd:attribute name="id" type="xsd:string"/>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
> <!-- END OF SCHEMA -->
> <book id="bk101">
> <author>Gambardella, Matthew</author>
> <title>XML Developer's Guide</title>
> <genre>Computer</genre>
> <cost>44.95</cost>
> <publish_date>2000-10-01</publish_date>
> <description>An in-depth look at creating applications with
> XML.</description>
> </book>
> </catalog>
> it's an microsoft example.
> Why when i try to validate this file the object return me that the file
> is valid?!
> (there is a <cost> element that is not declared in xsd schema).
> Anybody knows why'
> I've used this script to validate:
> <%
> ' Validate files and display output in text box.
> Dim sOutput
> sOutput = ValidateFile("novalid.xml")
> response.write sOutput
> Function ValidateFile(strFile)
> Path = " C:\inetpub\cmssviluppo1\wwwroot\sviluppo
\esempi2"
> ' Create an XML DOMDocument object.
> set x = CreateObject("MSXML2.DOMDocument.6.0")
> ' Load and validate the specified file into the DOM.
> x.async = False
> x.validateOnParse = True
> x.resolveExternals = True
> x.Load Path & "\" & strFile
> ' Return validation results in message to the user.
> If x.parseError.errorCode <> 0 Then
> ValidateFile = "Validation failed on " & _
> strFile & vbCrLf & _
> "=====================" & vbCrLf & _
> "Reason: " & x.parseError.reason & _
> vbCrLf & "Source: " & _
> x.parseError.srcText & _
> vbCrLf & "Line: " & _
> x.parseError.Line & vbCrLf
> Else
> ValidateFile = "Validation succeeded for " & _
> strFile & vbCrLf & _
> "======================" & _
> vbCrLf & x.xml & vbCrLf
> End If
> End Function
> %>
> Thanks!!
>|||ok, i do this but the page return me that the property is no supported
by object...
i use vbscript in asp page.
maybe i can't validate a file with an inline schema by vbscript?|||anybody can help me'|||ok, i have fix the problem.
UseInlineSchema is a second-level property. to set it true is necessary
type this:
x.setProperty "UseInlineSchema", true
http://windowssdk.msdn.microsoft.co...e3695c318bf.asp
thank

Saturday, February 25, 2012

Problem with default schema

Hi, Michael,
I understand that you would like to know why the default schema was not
initially set to "TEST" after you log on your SQL Server with the login
TEST.
If I have misunderstood, please let me know.
Unfortunately per my test in SQL Server Management Studio, I could not
reproduce your issue. My test process was as following:
1. Logged on my SQL Server instance with a sysadmin account and created a
login named "globaltest" with default master database;
2. Executed the statement:
USE TestDB
CREATE USER TEST FOR LOGIN globaltest WITH DEFAULT_SCHEMA = TEST
ALTER LOGIN globaltest WITH DEFAULT_DATABASE TestDB
3. Executed the statement:
CREATE SCHEMA TEST AUTHORIZATION TEST;
4. Changed a table dbo.T1 to TEST.T1;
5. Closed the current connection and connected to the SQL Server instance
with the login 'globaltest';
6. Executed the query:
SELECT * FROM T1;
Everything worked fine. Are there some differences between our tests?
I recommend that you run "SELECT CURRENT_USER" to check if the user TEST is
the current user after you log on your SQL Server with the TEST login. You
may also perform a test according to my steps to see if the issue occurs.
If you have any other questions or concerns, please feel free to let me
know.
Have a good day!
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====
Hi, Michael,
Thanks for your posting your script file here.
I reproduced your issue at my side. After carefully checked the script, I
found that the issue was caused by the sysadmin role assigned to the login.
If a login has the server role sysadmin, it will be assigned to dbo
automatically.
That is why you got dbo when you executed the statement "SELECT
CURRENT_USER".
If the sysadmin role is cancelled, the issue will not occur.
Please refer to:
Database Owner (dbo)
http://msdn2.microsoft.com/en-us/library/aa905208(sql.80).aspx
Hope this helps. Please feel free to let me know if you have any other
questions or concerns.
Have a good day!
Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====
|||Hi, Michael,
Thanks for your updating and response.
I am very glad to hear that the issue has been resolved. Please feel free
to let me know if you have any other questions or concerns.
Have a good day!
Charles Wang
Microsoft Online Community Support

Problem with default schema

Hi,
under SQL Server 2005 I greatet a user with:
USE MYDB
CREATE USER TEST FOR LOGIN TEST WITH DEFAULT_SCHEMA = TEST
ALTER LOGIN TEST WITH DEFAULT_DATABASE =MYDB
and schema:
CREATE SCHEMA TEST AUTHORIZATION TEST;
Connecting to the database using SQL Native Client (2005.9.1399.0) and ODBC
with the user "TEST" leads to default schema "DBO".
That means: Selecting a table using the unqualified name:
SELECT * FROM MYTABLE
leads to "objekt not found" error, if the table "MYTABLE" is part of the
schema "TEST"
after executing the statement
EXECUTE AS USER='TEST'
the statement
SELECT * FROM MYTABLE
succeeds.
Why the default schema is not initially set to "TEST" after connection?
Greetings
MichaelHi, Michael,
I understand that you would like to know why the default schema was not
initially set to "TEST" after you log on your SQL Server with the login
TEST.
If I have misunderstood, please let me know.
Unfortunately per my test in SQL Server Management Studio, I could not
reproduce your issue. My test process was as following:
1. Logged on my SQL Server instance with a sysadmin account and created a
login named "globaltest" with default master database;
2. Executed the statement:
USE TestDB
CREATE USER TEST FOR LOGIN globaltest WITH DEFAULT_SCHEMA = TEST
ALTER LOGIN globaltest WITH DEFAULT_DATABASE TestDB
3. Executed the statement:
CREATE SCHEMA TEST AUTHORIZATION TEST;
4. Changed a table dbo.T1 to TEST.T1;
5. Closed the current connection and connected to the SQL Server instance
with the login 'globaltest';
6. Executed the query:
SELECT * FROM T1;
Everything worked fine. Are there some differences between our tests?
I recommend that you run "SELECT CURRENT_USER" to check if the user TEST is
the current user after you log on your SQL Server with the TEST login. You
may also perform a test according to my steps to see if the issue occurs.
If you have any other questions or concerns, please feel free to let me
know.
Have a good day!
Charles Wang
Microsoft Online Community Support
========================================
=============
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...t/default.aspx.
========================================
==============
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
========================================
==============
This posting is provided "AS IS" with no warranties, and confers no rights.
========================================
==============|||underprocessable|||Hi, Michael,
Thanks for your posting your script file here.
I reproduced your issue at my side. After carefully checked the script, I
found that the issue was caused by the sysadmin role assigned to the login.
If a login has the server role sysadmin, it will be assigned to dbo
automatically.
That is why you got dbo when you executed the statement "SELECT
CURRENT_USER".
If the sysadmin role is cancelled, the issue will not occur.
Please refer to:
Database Owner (dbo)
http://msdn2.microsoft.com/en-us/library/aa905208(sql.80).aspx
Hope this helps. Please feel free to let me know if you have any other
questions or concerns.
Have a good day!
Charles Wang
Microsoft Online Community Support
========================================
=============
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications
If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...t/default.aspx.
========================================
==============
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
========================================
==============
This posting is provided "AS IS" with no warranties, and confers no rights.
========================================
==============|||Hi Charles,
many thanks for your help. In the execution environment it's not required
that the login is assigned to the sysadmin role.
So i'll change the skript!
Greetings
Michael|||Hi, Michael,
Thanks for your updating and response.
I am very glad to hear that the issue has been resolved. Please feel free
to let me know if you have any other questions or concerns.
Have a good day!
Charles Wang
Microsoft Online Community Support

Problem with default schema

Hi

I have a user database say Solumina. There is a login defined on the instance of sql 2005 server , say XYZ. There is also a user defined XYZ in the database mapped to the login 'XYZ' with the default schema as 'sfmfg' (Assume that 'sfmfg' schema already exists).

My question when I try to create a random table with the following syntax it gets created in the dbo schema instead of the sfmfg schema (I am using sfmfg login credentials).

create table t1(id int)

Can some 1 please help out.

Regards

Imtiaz

Is sfmfg a member of db_owner role? It is always safer to use 2-part names in your objects so that you know explicitly the schema for the object.