473,231 Members | 1,394 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

can't create schema for qualified attributes in element with default namespace

Hi,

I have a xml file like the one below

<?xml version="1.0" encoding="utf-8"?><e1
xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>

If I try to create a schema for it with Visual Studio, I get the error
"Failed to create a schema for this data file because:
Although this XML file is well formed, it contains structure that Data View
cannot display.

The 'http://tempuri.org/Source1.xsd:att1' atrribute is not declared. An
error occurred at , (7,8)"

However if I qualify the e1 element with e1 prefix it is happy.
I thought attributes namespace was independant of the element namespace.

I don't understand why I am getting this error.
Source1.xsd looks like this:

<?xml version="1.0" ?>
<xs:schema id="NewDataSet" targetNamespace="http://tempuri.org/Source1.xsd"
xmlns:mstns=http://tempuri.org/Source1.xsd
xmlns="http://tempuri.org/Source1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="e1">
<xs:complexType>
<xs:attribute name="att1" form="qualified" type="xs:string" />
<xs:attribute name="att2" form="qualified" type="xs:string" />
<xs:attribute name="rest" form="qualified" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="en-GB"
msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="e1" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Any help much appreciated.

Thanks
Martin
Nov 12 '05 #1
6 2535
Hi Martin,

Can you be a bit more specific. What version of VS are you using and how
are you creating a schema for your XML file? Also it looks like you already
have a schema, so I'm not sure what you are trying to achieve.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
"Martin" <x@y.z> wrote in message
news:us*************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a xml file like the one below

<?xml version="1.0" encoding="utf-8"?><e1
xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>

If I try to create a schema for it with Visual Studio, I get the error
"Failed to create a schema for this data file because:
Although this XML file is well formed, it contains structure that Data
View cannot display.

The 'http://tempuri.org/Source1.xsd:att1' atrribute is not declared. An
error occurred at , (7,8)"

However if I qualify the e1 element with e1 prefix it is happy.
I thought attributes namespace was independant of the element namespace.

I don't understand why I am getting this error.
Source1.xsd looks like this:

<?xml version="1.0" ?>
<xs:schema id="NewDataSet"
targetNamespace="http://tempuri.org/Source1.xsd"
xmlns:mstns=http://tempuri.org/Source1.xsd
xmlns="http://tempuri.org/Source1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="e1">
<xs:complexType>
<xs:attribute name="att1" form="qualified" type="xs:string" />
<xs:attribute name="att2" form="qualified" type="xs:string" />
<xs:attribute name="rest" form="qualified" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:Locale="en-GB" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="e1" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Any help much appreciated.

Thanks
Martin

Nov 12 '05 #2
I'm using VS.Net 2003 enterprise edition.

I'm trying to regnerate the xsd I already have because I changed the xml
file on which the schema was based.

The original schema was based on unqualified attributes. I have since made
the attributes qualified.

I *think* I want to end up with a schema for this xml file
<?xml version="1.0" encoding="utf-8"?>

<e3:e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>

where the attributes are in a different name space to the element (NB
element prefix is now e3), but on creating the schema for this doc, I am
simply told e3 is an undeclared namespace.

Ultimately I have 2 different xml files, shown below without name spaces:
source xml
<e1 att1="1" att2="2" rest="abc"/>

destination xml transformed from source
<e2 att1="1" att2="2" att3="a" att4="b" att5="c"/>

My xslt file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl=http://www.w3.org/1999/XSL/Transform
xmlns:MyAttrs="urn:MyAttrs"
xmlns:e1="http://tempuri.org/Source1.xsd">
<xsl:template match="e1:e1">
<e2>
<xsl:attribute name="e1:att1"><xsl:value-of select="@att1"/></xsl:attribute>
<xsl:attribute name="e1:att2"><xsl:value-of select="@att2"/></xsl:attribute>
<xsl:for-each select="MyAttrs:getAttrs(@rest)">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:for-each>
</e2>
</xsl:template>
</xsl:stylesheet>
I have used an xslt extension object to produce the attributes 3,4,5, and
the resulting xml file includes the namespace of the xslt extension object.

I want to use namespaces correctly, and thought the element namespace was
distinct from the attribute namespace.

Can you help me further?
Thanks
Martin

"Stan Kitsis [MSFT]" <sk***@microsoft.com> wrote in message
news:41********@news.microsoft.com...
Hi Martin,

Can you be a bit more specific. What version of VS are you using and how
are you creating a schema for your XML file? Also it looks like you
already have a schema, so I'm not sure what you are trying to achieve.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no
rights.
"Martin" <x@y.z> wrote in message
news:us*************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a xml file like the one below

<?xml version="1.0" encoding="utf-8"?><e1
xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>

If I try to create a schema for it with Visual Studio, I get the error
"Failed to create a schema for this data file because:
Although this XML file is well formed, it contains structure that Data
View cannot display.

The 'http://tempuri.org/Source1.xsd:att1' atrribute is not declared. An
error occurred at , (7,8)"

However if I qualify the e1 element with e1 prefix it is happy.
I thought attributes namespace was independant of the element namespace.

I don't understand why I am getting this error.
Source1.xsd looks like this:

<?xml version="1.0" ?>
<xs:schema id="NewDataSet"
targetNamespace="http://tempuri.org/Source1.xsd"
xmlns:mstns=http://tempuri.org/Source1.xsd
xmlns="http://tempuri.org/Source1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="e1">
<xs:complexType>
<xs:attribute name="att1" form="qualified" type="xs:string" />
<xs:attribute name="att2" form="qualified" type="xs:string" />
<xs:attribute name="rest" form="qualified" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:Locale="en-GB" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="e1" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Any help much appreciated.

Thanks
Martin


Nov 12 '05 #3
Hi Martin,

First, in your XML file you are using namespace prefix e3 without defining
it. You need to fix that:

<?xml version="1.0" encoding="utf-8"?>

<e3:e1 xmlns:e1="http://tempuri.org/Source1.xsd"

xmlns:e3="http://tempuri.org/Source3.xsd"

e1:att1="1" e1:att2="2"

e1:rest="345"/>
When generating a schema for this xml, you'll end up with two files (one for
each namespace):

<!-- e1 -->

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:tns="http://tempuri.org/Source1.xsd"

attributeFormDefault="unqualified"

elementFormDefault="qualified"

targetNamespace="http://tempuri.org/Source1.xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:attribute name="att1" type="xs:integer" />

<xs:attribute name="att2" type="xs:integer" />

<xs:attribute name="rest" type="xs:integer" />

</xs:schema>
<!-- e3 -->

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:e3="http://tempuri.org/Source3.xsd"
xmlns:e1="http://tempuri.org/Source1.xsd" attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://tempuri.org/Source3.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:import namespace="http://tempuri.org/Source1.xsd" />

<xs:element name="e1">

<xs:complexType>

<xs:attribute ref="e1:att1" use="required" />

<xs:attribute ref="e1:att2" use="required" />

<xs:attribute ref="e1:rest" use="required" />

</xs:complexType>

</xs:element>

</xs:schema>
--
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
"Martin" <x@y.z> wrote in message
news:u7**************@tk2msftngp13.phx.gbl...
I'm using VS.Net 2003 enterprise edition.

I'm trying to regnerate the xsd I already have because I changed the xml
file on which the schema was based.

The original schema was based on unqualified attributes. I have since
made the attributes qualified.

I *think* I want to end up with a schema for this xml file
<?xml version="1.0" encoding="utf-8"?>

<e3:e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>

where the attributes are in a different name space to the element (NB
element prefix is now e3), but on creating the schema for this doc, I am
simply told e3 is an undeclared namespace.

Ultimately I have 2 different xml files, shown below without name spaces:
source xml
<e1 att1="1" att2="2" rest="abc"/>

destination xml transformed from source
<e2 att1="1" att2="2" att3="a" att4="b" att5="c"/>

My xslt file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl=http://www.w3.org/1999/XSL/Transform
xmlns:MyAttrs="urn:MyAttrs"
xmlns:e1="http://tempuri.org/Source1.xsd">
<xsl:template match="e1:e1">
<e2>
<xsl:attribute name="e1:att1"><xsl:value-of
select="@att1"/></xsl:attribute>
<xsl:attribute name="e1:att2"><xsl:value-of
select="@att2"/></xsl:attribute>
<xsl:for-each select="MyAttrs:getAttrs(@rest)">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:for-each>
</e2>
</xsl:template>
</xsl:stylesheet>
I have used an xslt extension object to produce the attributes 3,4,5, and
the resulting xml file includes the namespace of the xslt extension
object.

I want to use namespaces correctly, and thought the element namespace was
distinct from the attribute namespace.

Can you help me further?
Thanks
Martin

"Stan Kitsis [MSFT]" <sk***@microsoft.com> wrote in message
news:41********@news.microsoft.com...
Hi Martin,

Can you be a bit more specific. What version of VS are you using and how
are you creating a schema for your XML file? Also it looks like you
already have a schema, so I'm not sure what you are trying to achieve.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no
rights.
"Martin" <x@y.z> wrote in message
news:us*************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a xml file like the one below

<?xml version="1.0" encoding="utf-8"?><e1
xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>

If I try to create a schema for it with Visual Studio, I get the error
"Failed to create a schema for this data file because:
Although this XML file is well formed, it contains structure that Data
View cannot display.

The 'http://tempuri.org/Source1.xsd:att1' atrribute is not declared. An
error occurred at , (7,8)"

However if I qualify the e1 element with e1 prefix it is happy.
I thought attributes namespace was independant of the element namespace.

I don't understand why I am getting this error.
Source1.xsd looks like this:

<?xml version="1.0" ?>
<xs:schema id="NewDataSet"
targetNamespace="http://tempuri.org/Source1.xsd"
xmlns:mstns=http://tempuri.org/Source1.xsd
xmlns="http://tempuri.org/Source1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="e1">
<xs:complexType>
<xs:attribute name="att1" form="qualified" type="xs:string" />
<xs:attribute name="att2" form="qualified" type="xs:string" />
<xs:attribute name="rest" form="qualified" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:Locale="en-GB" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="e1" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Any help much appreciated.

Thanks
Martin



Nov 12 '05 #4
Hi Stan,

I was hoping the schema for namespace e3 could be generated for me by
VS.Net.

Are you saying if I provide the xmlns uri it will then generate the xsd for
me?

Am I flogging a dead horse. Do I have to geneate the xsds manually?
Thanks again
Martin

"Stan Kitsis [MSFT]" <sk***@microsoft.com> wrote in message
news:41********@news.microsoft.com...
Hi Martin,

First, in your XML file you are using namespace prefix e3 without defining
it. You need to fix that:

<?xml version="1.0" encoding="utf-8"?>

<e3:e1 xmlns:e1="http://tempuri.org/Source1.xsd"

xmlns:e3="http://tempuri.org/Source3.xsd"

e1:att1="1" e1:att2="2"

e1:rest="345"/>
When generating a schema for this xml, you'll end up with two files (one
for each namespace):

<!-- e1 -->

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:tns="http://tempuri.org/Source1.xsd"

attributeFormDefault="unqualified"

elementFormDefault="qualified"

targetNamespace="http://tempuri.org/Source1.xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:attribute name="att1" type="xs:integer" />

<xs:attribute name="att2" type="xs:integer" />

<xs:attribute name="rest" type="xs:integer" />

</xs:schema>
<!-- e3 -->

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:e3="http://tempuri.org/Source3.xsd"
xmlns:e1="http://tempuri.org/Source1.xsd"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://tempuri.org/Source3.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:import namespace="http://tempuri.org/Source1.xsd" />

<xs:element name="e1">

<xs:complexType>

<xs:attribute ref="e1:att1" use="required" />

<xs:attribute ref="e1:att2" use="required" />

<xs:attribute ref="e1:rest" use="required" />

</xs:complexType>

</xs:element>

</xs:schema>
--
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
"Martin" <x@y.z> wrote in message
news:u7**************@tk2msftngp13.phx.gbl...
I'm using VS.Net 2003 enterprise edition.

I'm trying to regnerate the xsd I already have because I changed the xml
file on which the schema was based.

The original schema was based on unqualified attributes. I have since
made the attributes qualified.

I *think* I want to end up with a schema for this xml file
<?xml version="1.0" encoding="utf-8"?>

<e3:e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>

where the attributes are in a different name space to the element (NB
element prefix is now e3), but on creating the schema for this doc, I am
simply told e3 is an undeclared namespace.

Ultimately I have 2 different xml files, shown below without name spaces:
source xml
<e1 att1="1" att2="2" rest="abc"/>

destination xml transformed from source
<e2 att1="1" att2="2" att3="a" att4="b" att5="c"/>

My xslt file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl=http://www.w3.org/1999/XSL/Transform
xmlns:MyAttrs="urn:MyAttrs"
xmlns:e1="http://tempuri.org/Source1.xsd">
<xsl:template match="e1:e1">
<e2>
<xsl:attribute name="e1:att1"><xsl:value-of
select="@att1"/></xsl:attribute>
<xsl:attribute name="e1:att2"><xsl:value-of
select="@att2"/></xsl:attribute>
<xsl:for-each select="MyAttrs:getAttrs(@rest)">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:for-each>
</e2>
</xsl:template>
</xsl:stylesheet>
I have used an xslt extension object to produce the attributes 3,4,5, and
the resulting xml file includes the namespace of the xslt extension
object.

I want to use namespaces correctly, and thought the element namespace was
distinct from the attribute namespace.

Can you help me further?
Thanks
Martin

"Stan Kitsis [MSFT]" <sk***@microsoft.com> wrote in message
news:41********@news.microsoft.com...
Hi Martin,

Can you be a bit more specific. What version of VS are you using and
how are you creating a schema for your XML file? Also it looks like you
already have a schema, so I'm not sure what you are trying to achieve.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no
rights.
"Martin" <x@y.z> wrote in message
news:us*************@TK2MSFTNGP09.phx.gbl...
Hi,

I have a xml file like the one below

<?xml version="1.0" encoding="utf-8"?><e1
xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>

If I try to create a schema for it with Visual Studio, I get the error
"Failed to create a schema for this data file because:
Although this XML file is well formed, it contains structure that Data
View cannot display.

The 'http://tempuri.org/Source1.xsd:att1' atrribute is not declared. An
error occurred at , (7,8)"

However if I qualify the e1 element with e1 prefix it is happy.
I thought attributes namespace was independant of the element
namespace.

I don't understand why I am getting this error.
Source1.xsd looks like this:

<?xml version="1.0" ?>
<xs:schema id="NewDataSet"
targetNamespace="http://tempuri.org/Source1.xsd"
xmlns:mstns=http://tempuri.org/Source1.xsd
xmlns="http://tempuri.org/Source1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="e1">
<xs:complexType>
<xs:attribute name="att1" form="qualified" type="xs:string" />
<xs:attribute name="att2" form="qualified" type="xs:string" />
<xs:attribute name="rest" form="qualified" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true"
msdata:Locale="en-GB" msdata:EnforceConstraints="False">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="e1" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

Any help much appreciated.

Thanks
Martin



Nov 12 '05 #5
Martin,

I don't think you can have the files generated in VS2003. However,
VS2005 (in beta now) will generate both files for you.

Stan

On Tue, 25 Jan 2005 23:00:03 -0000, "Martin" <x@y.z> wrote:
Hi Stan,

I was hoping the schema for namespace e3 could be generated for me by
VS.Net.

Are you saying if I provide the xmlns uri it will then generate the xsd for
me?

Am I flogging a dead horse. Do I have to geneate the xsds manually?
Thanks again
Martin

"Stan Kitsis [MSFT]" <sk***@microsoft.com> wrote in message
news:41********@news.microsoft.com...
Hi Martin,

First, in your XML file you are using namespace prefix e3 without defining
it. You need to fix that:

<?xml version="1.0" encoding="utf-8"?>

<e3:e1 xmlns:e1="http://tempuri.org/Source1.xsd"

xmlns:e3="http://tempuri.org/Source3.xsd"

e1:att1="1" e1:att2="2"

e1:rest="345"/>
When generating a schema for this xml, you'll end up with two files (one
for each namespace):

<!-- e1 -->

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:tns="http://tempuri.org/Source1.xsd"

attributeFormDefault="unqualified"

elementFormDefault="qualified"

targetNamespace="http://tempuri.org/Source1.xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:attribute name="att1" type="xs:integer" />

<xs:attribute name="att2" type="xs:integer" />

<xs:attribute name="rest" type="xs:integer" />

</xs:schema>
<!-- e3 -->

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:e3="http://tempuri.org/Source3.xsd"
xmlns:e1="http://tempuri.org/Source1.xsd"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://tempuri.org/Source3.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:import namespace="http://tempuri.org/Source1.xsd" />

<xs:element name="e1">

<xs:complexType>

<xs:attribute ref="e1:att1" use="required" />

<xs:attribute ref="e1:att2" use="required" />

<xs:attribute ref="e1:rest" use="required" />

</xs:complexType>

</xs:element>

</xs:schema>
--
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
"Martin" <x@y.z> wrote in message
news:u7**************@tk2msftngp13.phx.gbl...
I'm using VS.Net 2003 enterprise edition.

I'm trying to regnerate the xsd I already have because I changed the xml
file on which the schema was based.

The original schema was based on unqualified attributes. I have since
made the attributes qualified.

I *think* I want to end up with a schema for this xml file
<?xml version="1.0" encoding="utf-8"?>

<e3:e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>

where the attributes are in a different name space to the element (NB
element prefix is now e3), but on creating the schema for this doc, I am
simply told e3 is an undeclared namespace.

Ultimately I have 2 different xml files, shown below without name spaces:
source xml
<e1 att1="1" att2="2" rest="abc"/>

destination xml transformed from source
<e2 att1="1" att2="2" att3="a" att4="b" att5="c"/>

My xslt file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl=http://www.w3.org/1999/XSL/Transform
xmlns:MyAttrs="urn:MyAttrs"
xmlns:e1="http://tempuri.org/Source1.xsd">
<xsl:template match="e1:e1">
<e2>
<xsl:attribute name="e1:att1"><xsl:value-of
select="@att1"/></xsl:attribute>
<xsl:attribute name="e1:att2"><xsl:value-of
select="@att2"/></xsl:attribute>
<xsl:for-each select="MyAttrs:getAttrs(@rest)">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:for-each>
</e2>
</xsl:template>
</xsl:stylesheet>
I have used an xslt extension object to produce the attributes 3,4,5, and
the resulting xml file includes the namespace of the xslt extension
object.

I want to use namespaces correctly, and thought the element namespace was
distinct from the attribute namespace.

Can you help me further?
Thanks
Martin

"Stan Kitsis [MSFT]" <sk***@microsoft.com> wrote in message
news:41********@news.microsoft.com...
Hi Martin,

Can you be a bit more specific. What version of VS are you using and
how are you creating a schema for your XML file? Also it looks like you
already have a schema, so I'm not sure what you are trying to achieve.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no
rights.
"Martin" <x@y.z> wrote in message
news:us*************@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I have a xml file like the one below
>
> <?xml version="1.0" encoding="utf-8"?><e1
> xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
> e1:rest="345"/>
>
> If I try to create a schema for it with Visual Studio, I get the error
> "Failed to create a schema for this data file because:
> Although this XML file is well formed, it contains structure that Data
> View cannot display.
>
> The 'http://tempuri.org/Source1.xsd:att1' atrribute is not declared. An
> error occurred at , (7,8)"
>
> However if I qualify the e1 element with e1 prefix it is happy.
> I thought attributes namespace was independant of the element
> namespace.
>
> I don't understand why I am getting this error.
> Source1.xsd looks like this:
>
> <?xml version="1.0" ?>
> <xs:schema id="NewDataSet"
> targetNamespace="http://tempuri.org/Source1.xsd"
> xmlns:mstns=http://tempuri.org/Source1.xsd
> xmlns="http://tempuri.org/Source1.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> attributeFormDefault="qualified" elementFormDefault="qualified">
> <xs:element name="e1">
> <xs:complexType>
> <xs:attribute name="att1" form="qualified" type="xs:string" />
> <xs:attribute name="att2" form="qualified" type="xs:string" />
> <xs:attribute name="rest" form="qualified" type="xs:string" />
> </xs:complexType>
> </xs:element>
> <xs:element name="NewDataSet" msdata:IsDataSet="true"
> msdata:Locale="en-GB" msdata:EnforceConstraints="False">
> <xs:complexType>
> <xs:choice maxOccurs="unbounded">
> <xs:element ref="e1" />
> </xs:choice>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> Any help much appreciated.
>
> Thanks
> Martin
>
>



Nov 12 '05 #6
VS.Net 2003 can generate xsds when no namespaces are used in the sample xml,
but I guess I'll have to do namespaced xsd myself.

Thanks for the answers
Martin

"Stan Kitsis" <sk*****@umich.edu> wrote in message
news:ok********************************@4ax.com...
Martin,

I don't think you can have the files generated in VS2003. However,
VS2005 (in beta now) will generate both files for you.

Stan

On Tue, 25 Jan 2005 23:00:03 -0000, "Martin" <x@y.z> wrote:
Hi Stan,

I was hoping the schema for namespace e3 could be generated for me by
VS.Net.

Are you saying if I provide the xmlns uri it will then generate the xsd
for
me?

Am I flogging a dead horse. Do I have to geneate the xsds manually?
Thanks again
Martin

"Stan Kitsis [MSFT]" <sk***@microsoft.com> wrote in message
news:41********@news.microsoft.com...
Hi Martin,

First, in your XML file you are using namespace prefix e3 without
defining
it. You need to fix that:

<?xml version="1.0" encoding="utf-8"?>

<e3:e1 xmlns:e1="http://tempuri.org/Source1.xsd"

xmlns:e3="http://tempuri.org/Source3.xsd"

e1:att1="1" e1:att2="2"

e1:rest="345"/>
When generating a schema for this xml, you'll end up with two files (one
for each namespace):

<!-- e1 -->

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:tns="http://tempuri.org/Source1.xsd"

attributeFormDefault="unqualified"

elementFormDefault="qualified"

targetNamespace="http://tempuri.org/Source1.xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:attribute name="att1" type="xs:integer" />

<xs:attribute name="att2" type="xs:integer" />

<xs:attribute name="rest" type="xs:integer" />

</xs:schema>
<!-- e3 -->

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns:e3="http://tempuri.org/Source3.xsd"
xmlns:e1="http://tempuri.org/Source1.xsd"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://tempuri.org/Source3.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:import namespace="http://tempuri.org/Source1.xsd" />

<xs:element name="e1">

<xs:complexType>

<xs:attribute ref="e1:att1" use="required" />

<xs:attribute ref="e1:att2" use="required" />

<xs:attribute ref="e1:rest" use="required" />

</xs:complexType>

</xs:element>

</xs:schema>
--
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
"Martin" <x@y.z> wrote in message
news:u7**************@tk2msftngp13.phx.gbl...
I'm using VS.Net 2003 enterprise edition.

I'm trying to regnerate the xsd I already have because I changed the
xml
file on which the schema was based.

The original schema was based on unqualified attributes. I have since
made the attributes qualified.

I *think* I want to end up with a schema for this xml file
<?xml version="1.0" encoding="utf-8"?>

<e3:e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1"
e1:att2="2"
e1:rest="345"/>

where the attributes are in a different name space to the element (NB
element prefix is now e3), but on creating the schema for this doc, I
am
simply told e3 is an undeclared namespace.

Ultimately I have 2 different xml files, shown below without name
spaces:
source xml
<e1 att1="1" att2="2" rest="abc"/>

destination xml transformed from source
<e2 att1="1" att2="2" att3="a" att4="b" att5="c"/>

My xslt file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl=http://www.w3.org/1999/XSL/Transform
xmlns:MyAttrs="urn:MyAttrs"
xmlns:e1="http://tempuri.org/Source1.xsd">
<xsl:template match="e1:e1">
<e2>
<xsl:attribute name="e1:att1"><xsl:value-of
select="@att1"/></xsl:attribute>
<xsl:attribute name="e1:att2"><xsl:value-of
select="@att2"/></xsl:attribute>
<xsl:for-each select="MyAttrs:getAttrs(@rest)">
<xsl:attribute name="{name()}"><xsl:value-of
select="."/></xsl:attribute>
</xsl:for-each>
</e2>
</xsl:template>
</xsl:stylesheet>
I have used an xslt extension object to produce the attributes 3,4,5,
and
the resulting xml file includes the namespace of the xslt extension
object.

I want to use namespaces correctly, and thought the element namespace
was
distinct from the attribute namespace.

Can you help me further?
Thanks
Martin

"Stan Kitsis [MSFT]" <sk***@microsoft.com> wrote in message
news:41********@news.microsoft.com...
> Hi Martin,
>
> Can you be a bit more specific. What version of VS are you using and
> how are you creating a schema for your XML file? Also it looks like
> you
> already have a schema, so I'm not sure what you are trying to achieve.
>
> --
> Stan Kitsis
> Program Manager, XML Technologies
> Microsoft Corporation
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
> "Martin" <x@y.z> wrote in message
> news:us*************@TK2MSFTNGP09.phx.gbl...
>> Hi,
>>
>> I have a xml file like the one below
>>
>> <?xml version="1.0" encoding="utf-8"?><e1
>> xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
>> e1:rest="345"/>
>>
>> If I try to create a schema for it with Visual Studio, I get the
>> error
>> "Failed to create a schema for this data file because:
>> Although this XML file is well formed, it contains structure that
>> Data
>> View cannot display.
>>
>> The 'http://tempuri.org/Source1.xsd:att1' atrribute is not declared.
>> An
>> error occurred at , (7,8)"
>>
>> However if I qualify the e1 element with e1 prefix it is happy.
>> I thought attributes namespace was independant of the element
>> namespace.
>>
>> I don't understand why I am getting this error.
>> Source1.xsd looks like this:
>>
>> <?xml version="1.0" ?>
>> <xs:schema id="NewDataSet"
>> targetNamespace="http://tempuri.org/Source1.xsd"
>> xmlns:mstns=http://tempuri.org/Source1.xsd
>> xmlns="http://tempuri.org/Source1.xsd"
>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
>> attributeFormDefault="qualified" elementFormDefault="qualified">
>> <xs:element name="e1">
>> <xs:complexType>
>> <xs:attribute name="att1" form="qualified" type="xs:string" />
>> <xs:attribute name="att2" form="qualified" type="xs:string" />
>> <xs:attribute name="rest" form="qualified" type="xs:string" />
>> </xs:complexType>
>> </xs:element>
>> <xs:element name="NewDataSet" msdata:IsDataSet="true"
>> msdata:Locale="en-GB" msdata:EnforceConstraints="False">
>> <xs:complexType>
>> <xs:choice maxOccurs="unbounded">
>> <xs:element ref="e1" />
>> </xs:choice>
>> </xs:complexType>
>> </xs:element>
>> </xs:schema>
>>
>> Any help much appreciated.
>>
>> Thanks
>> Martin
>>
>>
>
>

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Olaf Meyer | last post by:
Apprentently xerces 2.6.0 (Java) does not validate against contraints specified in the schema (e.g. constraints specified via unique element). The validation works with the XML editor I'm using...
2
by: Jamie Chen | last post by:
Hello, need some help to understand this.(I am using DevSutio.Net) I set the default name space to be "http://www.w3.org/2001/XMLSchema" in my XML schema and I use my XML schema as the default...
2
by: Stanimir Stamenkov | last post by:
I'm trying to find out if it is permissible to include a schema document with absent target namespace to a schema with specified target namespace, and if it is, what are the rules to resolve the...
2
by: Tarren | last post by:
Hi: The problem I am having is when I validate an xml file to a schema, it is erroring out every element. I think this has something to do with me defining/referencing the namespaces. I have...
5
by: Lemon Tree | last post by:
Hello everybody. I have a problem with Schema Definitions and I cannot figure out how to solve it (provided that it could be solved :)) Here we go... Let's suppose to have a simple XML file...
0
by: Andrew Brook | last post by:
Hi everyone, I've been going through an article i found on MSDN (http://msdn.microsoft.com/msdnmag/issues/02/12/WebServicesDesign/) concerning designing the messages for a webservice in a schema...
1
by: mflll | last post by:
How does one say in one schema that one wants an element defined in another schema. For example, I want to include in the Employee definition, an Address element defined in the schema...
13
by: Bill Nguyen | last post by:
Is it possible to create your won XSD to use with .NET based on an XML content? For example the one below: <?xml version="1.0"?> <pcats:FuelsDoc...
1
by: tthunder | last post by:
Hi @all, Please check the following XML file and XML schema definition below first: ------- XML File (full): ------- <?xml version="1.0" encoding="UTF-8"?>
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.