473,796 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\Pa ckages\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 2162
"Don" <do************ *@hotmail.com> wrote in message news:Oq******** ******@TK2MSFTN GP09.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.x sd" 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\Pa ckages\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.x sd"
templatename="i Clas_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="Strin g" ONCHANGE="" />
</GROUP>
</SUBSECTION>
</SECTION>
</WEBFORM>

---Resulting "View Source" from browser---
*Without the namespace reference* -- This is the incorrect one
<xsl:styleshe et 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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template name="iClas_for m"><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******** ******@TK2MSFTN GP14.phx.gbl...
"Don" <do************ *@hotmail.com> wrote in message

news:Oq******** ******@TK2MSFTN GP09.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%******** ********@TK2MSF TNGP09.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:styleshe et 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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template name="iClas_for m"><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.x sd"
templatename="i Clas_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="Strin g" 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.x sd: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 XmlNamespaceMan ager 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.

XmlNamespaceMan ager nsMan = new XmlNamespaceMan ager( doc.NameTable);
nsMan.AddNamesp ace("tns", "http://tempuri.org/formgenerator.x sd");
XmlNode templName = doc.SelectSingl eNode(
"//tns:WEBFORM/@tns:templatena me",
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:style sheet">
<xsl:attribut e name="version"> 1.0</xsl:attribute>
<xsl:element name="xsl:templ ate">
<xsl:attribut e name="name"><xs l: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:otherwis e>
<form>
<xsl:if test="/WEBFORM/@ONSUBMIT"><xsl :attribute
name="onsubmit" ><xsl:value-of select="/WEBFORM/@ONSUBMIT"
/></xsl:attribute></xsl:if>
<xsl:attribut e name="method">< xsl:value-of select="/WEBFORM/@method"
/></xsl:attribute>< xsl:attribute name="name"><xs l: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******** ******@tk2msftn gp13.phx.gbl...
"Don" <do************ *@hotmail.com> wrote in message

news:O%******** ********@TK2MSF TNGP09.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:styleshe et 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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template name="iClas_for m"><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.x sd"
templatename="i Clas_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="Strin g" 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.x sd: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 XmlNamespaceMan ager 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.

XmlNamespaceMan ager nsMan = new XmlNamespaceMan ager( doc.NameTable);
nsMan.AddNamesp ace("tns", "http://tempuri.org/formgenerator.x sd");
XmlNode templName = doc.SelectSingl eNode(
"//tns:WEBFORM/@tns:templatena me",
nsMan
);
Derek Harmon

Nov 12 '05 #5
"Don" <do************ *@hotmail.com> wrote in message news:uy******** ******@TK2MSFTN GP10.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:attribut e> or attributeFormDe fault=
'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 >).

- - - nsAwareTransfor m.xsl
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:ns="http://tempuri.org/formgenerator.x sd" >
<!--
. . .
-->
<xsl:template match="/">
<xsl:element name="xsl:style sheet">
<xsl:attribut e name="version"> 1.0</xsl:attribute>

<xsl:element name="xsl:templ ate">
<xsl:attribut e 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:attribut e name="rel">styl esheet</xsl:attribute>
<xsl:attribut e name="type">tex t/css</xsl:attribute>
<xsl:attribut e 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:attribut e name="type">tex t/javascript</xsl:attribute>
<xsl:attribut e 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:otherwis e>
<xsl:element name="form">
<xsl:if test="/ns:WEBFORM/@ONSUBMIT">
<xsl:attribut e name="onsubmit" >
<xsl:value-of
select="/ns:WEBFORM/@ONSUBMIT"/>
</xsl:attribute>
</xsl:if>
<xsl:attribut e name="method">
<xsl:value-of
select="/ns:WEBFORM/@method"/>
</xsl:attribute>
<xsl:attribut e name="name">
<xsl:value-of
select="/ns:WEBFORM/@name" />
</xsl:attribute>
<xsl:attribut e 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
2594
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 example right now when I hit '<' i get a list of controls like <asp:(somecontrols)>. I was wondering if there is a way so that when i hit '<' I will also get a list like <mycompany:(mycustomcontrols)>. Any pointers or documentation would be...
0
1503
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 put a custom XSD in the schemas\xml directory and it works pretty great. It's largely based on the asp.xsd. My problem is that while this works great for most controls, providing Intellisense whenever I have: <foo:FooTextBox runat=server......
1
1897
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 not display members not contained inside of Control (which my control is inherited from). Despite this, program execution still works fine; Intellisense just stops displaying these members, is all. If I close down Visual Studio and open it again,...
0
1005
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 popup in the list of possible controls. I see lots of "<ASP:" and other tags. Why is this? Is it possible to add the intellisense control? I know that class libraries cannot use intellisense from the .aspx page in VS.NET, but I thought that...
12
4837
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. When this happens its time to close VS C++.NET, which can only be done via the Windows Task Manager. I tried repairing C++. It did seem to help, but the problem is back a few hours later. I will try creating a new project, copy over source files,...
2
1183
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 doesn't show any code completion dialog when I type "<atlas:". At home I have exactly the same version of VS 2005, and it works perfectly. I even had to format and reinstall everything here, but it still doesn't work.
7
1704
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 VS2005. Any suggestions on what I could include within my control to enable this functionality? Thanks,
1
1781
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 EXTERNAL, so I'd like these to drop down in an intellisense box. Is it possible? Thanks, Jon
4
1930
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 age to recreate intellisense information for the autogenerated classes. Is there any way whatsoever that I can turn off intellisense generation on a per-project or per-class manner? I had hoped that would stop the generation of intellisense info...
0
9679
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10172
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.