473,405 Members | 2,373 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,405 software developers and data experts.

getting intellisense for custom XML

Don
Hi:
I have created an xsd from my xml document. I pop this xsd in the
following directory: C:\program files\Microsoft Visual Studio .NET
2003\Common7\Packages\schemas\xml. That give me intellisense when I specify
the name space. But leaving hte namespace in messes up my transforms.

Is there any way to get this intellisense functionality without adding the
namespace all the time?

Thanks,

Do
Nov 12 '05 #1
5 2143
"Don" <do*************@hotmail.com> wrote in message news:Oq**************@TK2MSFTNGP09.phx.gbl...
That give me intellisense when I specify the name space.
But leaving hte namespace in messes up my transforms.

Is there any way to get this intellisense functionality without
adding the namespace all the time?


I don't believe there is. That would be very bad for me, if I
had XML schema documents in that folder to get Intelli-
Sense too, and no namespaces, and some of the elements
in my schema collided with names in your schema.

Since changing Microsoft's Visual Studio .NET is probably
a longshot, maybe we can have greater success changing
your transforms so they aren't screwed up by having a
namespace in them when you're doing transformations. :-)

Can you post some excerpts of your stylesheets and instance
documents where you're encountering these problems, and
then I or others in the newsgroup can suggest solutions to
make your transforms namespace-aware?
Derek Harmon
Nov 12 '05 #2
Don
Here is some code:
The xmlns="http://tempuri.org/formgenerator.xsd" is the namespace reference
I am talking about. I must add this to the root of the document to get
intellisense functionality. This file sits in C:\Program Files\Microsoft
Visual Studio .NET 2003\Common7\Packages\schemas\xml with all the other xsd
schemas used for intellisense.

If I leave that name space reference in the document, my document renders
incorrectly (see below). I must remove it in order to render correctly. So
it's an annoyance adding and removing this thing all the time just to get
some intellisense. As you mentioned, I should probably make all my
transformations "namespace aware"... and how do I do that in this case?

Thanks,

Don

---XML Code---
<?xml version="1.0" encoding="utf-8" ?>
<WEBFORM xmlns="http://tempuri.org/formgenerator.xsd"
templatename="iClas_form">
<SECTION VERSION="1" SName="form" WIDTH="646">
<SUBSECTION SName="form1">
<GROUP>
<INPUT VERSION="1" TYPE="Text" FName="1. Could I have your first name
please?" Name="FirstName"
XPath="/document/iClas_Contact[index='1']/Borrower/FirstName"
MAXLENGTH="15" SIZE="36"
DataType="String" ONCHANGE="" />
</GROUP>
</SUBSECTION>
</SECTION>
</WEBFORM>

---Resulting "View Source" from browser---
*Without the namespace reference* -- This is the incorrect one
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="">
<form method="" name="" action="">
</form>
</xsl:template>
</xsl:stylesheet>

*With the namespace reference* --This is the correct one
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="iClas_form"><link rel="stylesheet" type="text/css"
href="/CSS/corporate.css" /><script type="text/javascript"
src="/include/helper.js"></script></xsl:template>
</xsl:stylesheet>


"Derek Harmon" <lo*******@msn.com> wrote in message
news:eB**************@TK2MSFTNGP14.phx.gbl...
"Don" <do*************@hotmail.com> wrote in message

news:Oq**************@TK2MSFTNGP09.phx.gbl...
That give me intellisense when I specify the name space.
But leaving hte namespace in messes up my transforms.

Is there any way to get this intellisense functionality without
adding the namespace all the time?


I don't believe there is. That would be very bad for me, if I
had XML schema documents in that folder to get Intelli-
Sense too, and no namespaces, and some of the elements
in my schema collided with names in your schema.

Since changing Microsoft's Visual Studio .NET is probably
a longshot, maybe we can have greater success changing
your transforms so they aren't screwed up by having a
namespace in them when you're doing transformations. :-)

Can you post some excerpts of your stylesheets and instance
documents where you're encountering these problems, and
then I or others in the newsgroup can suggest solutions to
make your transforms namespace-aware?
Derek Harmon

Nov 12 '05 #3
"Don" <do*************@hotmail.com> wrote in message news:O%****************@TK2MSFTNGP09.phx.gbl...
If I leave that name space reference in the document, my document renders
incorrectly (see below). I must remove it in order to render correctly. So
it's an annoyance adding and removing this thing all the time just to get
some intellisense. As you mentioned, I should probably make all my
transformations "namespace aware"... and how do I do that in this case?
You show two .xsl transformations. One looks 'empty' and you state
that's what gets created without a namespace declaration?

: : *Without the namespace reference* -- This is the incorrect one
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="">
<form method="" name="" action="">
</form>
</xsl:template>
</xsl:stylesheet>
The other has content, although it has no main template, it doesn't
seem to depend on any XML node set, and I can't see how it's been
executed. This you've stated has a namespace declaration.

: : *With the namespace reference* --This is the correct one
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="iClas_form"><link rel="stylesheet" type="text/css"
href="/CSS/corporate.css" /><script type="text/javascript"
src="/include/helper.js"></script></xsl:template>
</xsl:stylesheet>
If having the namespace declaration produces the correct
stylesheet, and produces IntelliSense from the schema, the
problem is what?

OK, let's look at the XML document.
<?xml version="1.0" encoding="utf-8" ?>
<WEBFORM xmlns="http://tempuri.org/formgenerator.xsd"
templatename="iClas_form">
<SECTION VERSION="1" SName="form" WIDTH="646">
<SUBSECTION SName="form1">
<GROUP>
<INPUT VERSION="1" TYPE="Text" FName="1. Could I have your first name
please?" Name="FirstName"
XPath="/document/iClas_Contact[index='1']/Borrower/FirstName"
MAXLENGTH="15" SIZE="36"
DataType="String" ONCHANGE="" />
</GROUP>
</SUBSECTION>
</SECTION>
</WEBFORM>


My guess is you're reading this XML in and generating the XSLT.
Whatever program is reading this takes the templatename attribute
value, iClas_form, and puts it into the stylesheet.

Now, if having the namespace URI declared is causing the template-
name attribute to not be found, then it's conceivable an empty name
attribute will be generated in the stylesheet.

What you have to do is change the code you're using to select that
attribute to respect the http://tempuri.org/formgenerator.xsd name-
space URI, because when there's a namespace declaration your
document doesn't contain a templatename attribute. Instead, it
contains a "http://tempuri.org/formgenerator.xsd:templatename"
attribute (which is distinguishable from the non-namespace
qualified "templatename").

You haven't shown the program code that's selecting the
templatename attribute, so I can't provide anymore details.
However, if you're using SelectNodes to use XPath to find
it, then you need to create an XmlNamespaceManager w/
a prefix associated with http://tempuri.org/formgenerator.xsd
and use that prefix in your XPath expression. Then use this
prefix-qualified XPath expression and the XmlNamespace-
Manager you created in the call to SelectNodes.

XmlNamespaceManager nsMan = new XmlNamespaceManager( doc.NameTable);
nsMan.AddNamespace("tns", "http://tempuri.org/formgenerator.xsd");
XmlNode templName = doc.SelectSingleNode(
"//tns:WEBFORM/@tns:templatename",
nsMan
);
Derek Harmon
Nov 12 '05 #4
Don
Derek:

I forgot to include the xsl template that is performing the transform.
This provides the two outputs (correct and incorrect) below.
I am not using any code. The XML and XSL documents are not manipulated at
all. I guess I just need some code to ignore or handle the namespace
reference at the root of the document. If I need to do something different,
let me know.

Thanks,

Do

Here it is:

<xsl:template match="/">
<xsl:element name="xsl:stylesheet">
<xsl:attribute name="version">1.0</xsl:attribute>
<xsl:element name="xsl:template">
<xsl:attribute name="name"><xsl:value-of select="/WEBFORM/@templatename"
/></xsl:attribute>
<xsl:if test="/WEBFORM/@CSS='1'">
<xsl:value-of disable-output-escaping="yes" select="/WEBFORM/CSSREF" />
<link rel="stylesheet" type="text/css" href="/CSS/corporate.css" />
</xsl:if>
<xsl:if test="/WEBFORM/@JS='1'">
<xsl:value-of disable-output-escaping="yes" select="/WEBFORM/JS" />
<script type="text/javascript" src="/include/helper.js"></script>
</xsl:if>
<xsl:choose>
<xsl:when test="/WEBFORM/@NOFORMTAG='1'">
<xsl:apply-templates />
</xsl:when>
<xsl:otherwise>
<form>
<xsl:if test="/WEBFORM/@ONSUBMIT"><xsl:attribute
name="onsubmit"><xsl:value-of select="/WEBFORM/@ONSUBMIT"
/></xsl:attribute></xsl:if>
<xsl:attribute name="method"><xsl:value-of select="/WEBFORM/@method"
/></xsl:attribute><xsl:attribute name="name"><xsl:value-of
select="/WEBFORM/@name" /></xsl:attribute><xsl:attribute
name="action"><xsl:value-of select="/WEBFORM/@action" /></xsl:attribute>
<xsl:apply-templates />
</form>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:element>
</xsl:template>


"Derek Harmon" <lo*******@msn.com> wrote in message
news:Op**************@tk2msftngp13.phx.gbl...
"Don" <do*************@hotmail.com> wrote in message

news:O%****************@TK2MSFTNGP09.phx.gbl...
If I leave that name space reference in the document, my document renders incorrectly (see below). I must remove it in order to render correctly. So it's an annoyance adding and removing this thing all the time just to get some intellisense. As you mentioned, I should probably make all my
transformations "namespace aware"... and how do I do that in this case?


You show two .xsl transformations. One looks 'empty' and you state
that's what gets created without a namespace declaration?

: :
*Without the namespace reference* -- This is the incorrect one
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="">
<form method="" name="" action="">
</form>
</xsl:template>
</xsl:stylesheet>


The other has content, although it has no main template, it doesn't
seem to depend on any XML node set, and I can't see how it's been
executed. This you've stated has a namespace declaration.

: :
*With the namespace reference* --This is the correct one
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="iClas_form"><link rel="stylesheet" type="text/css"
href="/CSS/corporate.css" /><script type="text/javascript"
src="/include/helper.js"></script></xsl:template>
</xsl:stylesheet>


If having the namespace declaration produces the correct
stylesheet, and produces IntelliSense from the schema, the
problem is what?

OK, let's look at the XML document.
<?xml version="1.0" encoding="utf-8" ?>
<WEBFORM xmlns="http://tempuri.org/formgenerator.xsd"
templatename="iClas_form">
<SECTION VERSION="1" SName="form" WIDTH="646">
<SUBSECTION SName="form1">
<GROUP>
<INPUT VERSION="1" TYPE="Text" FName="1. Could I have your first name please?" Name="FirstName"
XPath="/document/iClas_Contact[index='1']/Borrower/FirstName"
MAXLENGTH="15" SIZE="36"
DataType="String" ONCHANGE="" />
</GROUP>
</SUBSECTION>
</SECTION>
</WEBFORM>


My guess is you're reading this XML in and generating the XSLT.
Whatever program is reading this takes the templatename attribute
value, iClas_form, and puts it into the stylesheet.

Now, if having the namespace URI declared is causing the template-
name attribute to not be found, then it's conceivable an empty name
attribute will be generated in the stylesheet.

What you have to do is change the code you're using to select that
attribute to respect the http://tempuri.org/formgenerator.xsd name-
space URI, because when there's a namespace declaration your
document doesn't contain a templatename attribute. Instead, it
contains a "http://tempuri.org/formgenerator.xsd:templatename"
attribute (which is distinguishable from the non-namespace
qualified "templatename").

You haven't shown the program code that's selecting the
templatename attribute, so I can't provide anymore details.
However, if you're using SelectNodes to use XPath to find
it, then you need to create an XmlNamespaceManager w/
a prefix associated with http://tempuri.org/formgenerator.xsd
and use that prefix in your XPath expression. Then use this
prefix-qualified XPath expression and the XmlNamespace-
Manager you created in the call to SelectNodes.

XmlNamespaceManager nsMan = new XmlNamespaceManager( doc.NameTable);
nsMan.AddNamespace("tns", "http://tempuri.org/formgenerator.xsd");
XmlNode templName = doc.SelectSingleNode(
"//tns:WEBFORM/@tns:templatename",
nsMan
);
Derek Harmon

Nov 12 '05 #5
"Don" <do*************@hotmail.com> wrote in message news:uy**************@TK2MSFTNGP10.phx.gbl...
I forgot to include the xsl template that is performing the transform.
That addition definitely clears matters up. :-)
I guess I just need some code to ignore or handle the namespace
reference at the root of the document. If I need to do something
different, let me know.


Two very simple changes: add an xmlns declaration to the <xsl:stylesheet>
element of your primary XSLT transform that associates some prefix
with the namespace URI: http://tempuri.org/formgenerator.xsd.

Then, use this prefix for all elements in the template's XPath expressions
(it's not normally necessary to prefix the attributes, because attributes by
default will be unqualified, unless you're using an XML schema with an
attributeForm='qualified' on an <xsd:attribute> or attributeFormDefault=
'qualified' on the <xsd:schema>).

An optional third step is to use <xsl:element> for <form>, <link> and
<script> tags, otherwise you may get the XML namespace declaration
repeatedly showing up. I demonstrate this here.

Here's the fixed-up template (and xmlns on the <xsl:stylesheet>).

- - - nsAwareTransform.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns="http://tempuri.org/formgenerator.xsd" >
<!--
. . .
-->
<xsl:template match="/">
<xsl:element name="xsl:stylesheet">
<xsl:attribute name="version">1.0</xsl:attribute>

<xsl:element name="xsl:template">
<xsl:attribute name="name">
<xsl:value-of select="/ns:WEBFORM/@templatename"/>
</xsl:attribute>
<xsl:if test="/ns:WEBFORM/@CSS='1'">
<xsl:value-of disable-output-escaping="yes"
select="/ns:WEBFORM/ns:CSSREF" />
<!-- <link rel="stylesheet" type="text/css" href="/CSS/corporate.css" /> -->
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
<xsl:attribute name="href">/CSS/corporate.css</xsl:attribute>
</xsl:element>
</xsl:if>

<xsl:if test="/ns:WEBFORM/@JS='1'">
<!-- <script type="text/javascript" src="/include/helper.js"></script> -->
<xsl:element name="script">
<xsl:attribute name="type">text/javascript</xsl:attribute>
<xsl:attribute name="src">/include/helper.js</xsl:attribute>
<xsl:value-of disable-output-escaping="yes"
select="/ns:WEBFORM/ns:JS" />
</xsl:element>
</xsl:if>

<xsl:choose>
<xsl:when test="/ns:WEBFORM/@NOFORMTAG='1'">
<xsl:apply-templates />
</xsl:when>
<xsl:otherwise>
<xsl:element name="form">
<xsl:if test="/ns:WEBFORM/@ONSUBMIT">
<xsl:attribute name="onsubmit">
<xsl:value-of
select="/ns:WEBFORM/@ONSUBMIT"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="method">
<xsl:value-of
select="/ns:WEBFORM/@method"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of
select="/ns:WEBFORM/@name" />
</xsl:attribute>
<xsl:attribute name="action">
<xsl:value-of select="/ns:WEBFORM/@action" />
</xsl:attribute>
<xsl:apply-templates />
</xsl:element> <!-- end form -->
</xsl:otherwise>
</xsl:choose>

</xsl:element> <!-- end xsl:template -->
</xsl:element> <!-- end xsl:stylesheet -->

</xsl:template>
<!--
.. . .
-->
</xsl:stylesheet>
- - -

Notice how the ns namespace prefix is declared in the xsl:stylesheet
of this stylesheet, and then used as the prefix locating the elements in
your source XML document. This is what makes the stylesheet NS
aware.

When I added 3 attributes to your original example XML's WEBFORM
element (CSS="1", JS="1" and NOFORMTAG="1"), I was then able
to produce the same XSLT as you indicated in your correct example
using this stylesheet and Saxon.

If you have any other questions about how this works, just ask. :-)
Derek Harmon
Nov 12 '05 #6

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

Similar topics

2
by: Nick Kafenzakis | last post by:
Hi, I am thinking about creating some custom server controls in Visual Studio .NET 2003 using VB.NET. One thing I am wondering about is how I can get the control to show up in the IDE....for...
0
by: James Bright | last post by:
I have set up custom Intellisense for our project. (In a nutshell, we will have ASP.NET controls based on many of the statndard WebControls, but with a few extensions that we will be adding). I've...
1
by: Yaron | last post by:
Hi, I have a custom ListView-type control that I designed a few months ago. The control is completely stable and functional. However, often, the Visual Studio .NET IDE's Intellisense will lose and...
0
by: William Parker | last post by:
I built a custom web control and have registered it correctly within my ..aspx page. The control is working fine at run time as well. However when I type "<" character I do not see my control...
12
by: Peteroid | last post by:
I was creating my application just fine for the last 3 weeks or so. Then, starting this morning, IntelliSense seems to be having problems. It goes into a locked 'Updating IntelliSense..." mode....
2
by: Natan Vivo | last post by:
Can anyone tell me what exactly what makes intellisense works for custom controls in aspx pages in VS 2005? I just installed Atlas in my office computer, created a new atlas project and it...
7
by: Andrew Robinson | last post by:
I have an overridden control: public class DJGridView : GridView { } All works great except that I loose IntelliSense for all of the child elements while editing the HTML file from within...
1
by: Jon | last post by:
Hello all, I have created a custom web.confif section and all works fine. However, is there a way to add intellisense to the elements? For example, one of the elements can only be INTERNAL or...
4
by: Clive Dixon | last post by:
I have a project as part of a solution which contains a very large number of autogenerated class files. When compiling the solution and the autogenerated files have changed, visual studio takes an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.