473,466 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how can I do this ?

Hi, I have problem with namespaces and attributes.
I want to get this:

<grammar xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"


I have the following XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />

<xsl:template match="/">
<xsl:element name="grammar">
<xsl:attribute name="xmlns">http://www.w3.org/2001/06/grammar</xsl:attribute>
<xsl:attribute name="sapi"
namespace="xmlns">http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions</xsl:attribute>
</xsl:element>
</xsl:template>
but I can't get what I want, it don't work. Can anyone help me out?
Thanks in advance.
Julio
Jul 20 '05 #1
7 1659
Strange, it _does_ work for me... but i appended
</xsl:stylesheet>
to your stylesheet :)

w.kind regards
Pitter

Julio wrote:
Hi, I have problem with namespaces and attributes.
I want to get this:

<grammar xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"
I have the following XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />

<xsl:template match="/">
<xsl:element name="grammar">
<xsl:attribute name="xmlns">http://www.w3.org/2001/06/grammar</xsl:attribute>
<xsl:attribute name="sapi"
namespace="xmlns">http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions</xsl:attribute>
</xsl:element>
</xsl:template>
but I can't get what I want, it don't work. Can anyone help me out?
Thanks in advance.
Julio


Jul 20 '05 #2
In article <8b**************************@posting.google.com >,
Julio <jk*****@hotpop.com> wrote:

% I want to get this:
%
% <grammar xmlns="http://www.w3.org/2001/06/grammar"
% xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"
% >

% I have the following XSLT:
%
% <?xml version="1.0" encoding="UTF-8"?>
% <xsl:stylesheet version="1.0"
% xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
% <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
%
% <xsl:template match="/">
% <xsl:element name="grammar">
% <xsl:attribute
% name="xmlns">http://www.w3.org/2001/06/grammar</xsl:attribute>

Don't treat the name space declaration as an ordinary attribute. Just
declare the name space, and it should be emitted as needed. For instance,
if you put

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions">

at the top of your style sheet, you can put

<grammar>
<sapi:excuse-my-ignorance/>
</grammar>

In your template, and it will come out with the appropriate name space
declarations.

--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #3
Hi, I'm using XmlSpy 2004 and I don't what I want.
Which xslt engine are you using?
Cheers!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4
Hi, I supose if I try what you say it will work. However, I only need
the attribute
'xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"
' to say to the grammar compiler to use some extension to build the
binary file of the grammar.
Let me show what I need to get, you will see that I don't need a tag
<sapi:whatever ... />.

<grammar xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"
xml:lang="en-US" tag-format="semantics-ms/1.0" version="1.0"
mode="voice">
<rule id="root" scope="public">
<tag>$.Result={}</tag>
<one-of>
<item>
<item>Boston Fortune</item>
<tag>$.Result.FirstName=Boston</tag>
<tag>$.Result.LastName=Fortune</tag>
<tag>$.Result.Extension=123</tag>
<tag>$.Result.Department=Development</tag>
</item>
<item>
<item>Londo Deamon</item>
<tag>$.Result.FirstName=Londo</tag>
<tag>$.Result.LastName=Deamon</tag>
<tag>$.Result.Extension=456</tag>
<tag>$.Result.Department=Development</tag>
</item>
<item>
<item>Oxford Cowboy</item>
<tag>$.Result.FirstName=Oxford</tag>
<tag>$.Result.LastName=Cowboy</tag>
<tag>$.Result.Extension=789</tag>
<tag>$.Result.Department=Research</tag>
</item>
</one-of>
</rule>
</grammar>
Now I have it working with the following xslt, but I beleive it's a
workaround and not a good solution:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"
xmlns="http://www.w3.org/2001/06/grammar">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />

<xsl:template match="/">
<grammar
xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"
xml:lang="en-US" tag-format="semantics-ms/1.0" version="1.0"
mode="voice" xmlns="http://www.w3.org/2001/06/grammar">
<!--
<xsl:element name="grammar">
<xsl:attribute
name="xmlns">http://www.w3.org/2001/06/grammar</xsl:attribute>
<xsl:attribute
name="xmlns:sapi">http://schemas.microsoft.com/Speech/2002/06/SRGSExtens
ions</xsl:attribute>

<xsl:attribute name="xml:lang">en-US</xsl:attribute>
<xsl:attribute name="tag-format">semantics-ms/1.0</xsl:attribute>
<xsl:attribute name="version">1.0</xsl:attribute>
<xsl:attribute name="mode">voice</xsl:attribute>
-->
<xsl:element name="rule">
<xsl:attribute name="id">root</xsl:attribute>
<xsl:attribute name="scope">public</xsl:attribute>

<xsl:call-template name="tag">
<xsl:with-param name="name">$.Result</xsl:with-param>
<xsl:with-param name="value">{}</xsl:with-param>
</xsl:call-template>

<xsl:element name="one-of">
<xsl:for-each select="//User">
<xsl:call-template name="user" />
</xsl:for-each>
</xsl:element>
</xsl:element>
<!--
</xsl:element>
-->
</grammar>
</xsl:template>

<xsl:template name="tag">
<xsl:param name="name" />
<xsl:param name="value" />

<xsl:element name="tag">
<xsl:value-of select="$name" />
<xsl:text>=</xsl:text>
<xsl:value-of select="$value" />
</xsl:element>
</xsl:template>

<xsl:template name="user">
<xsl:element name="item">
<xsl:element name="item">
<xsl:value-of select="./FirstName" />
<xsl:text> </xsl:text>
<xsl:value-of select="./LastName" />
</xsl:element>

<xsl:call-template name="tag">
<xsl:with-param name="name">$.Result.FirstName</xsl:with-param>
<xsl:with-param name="value"><xsl:value-of select="./FirstName"
/></xsl:with-param>
</xsl:call-template>

<xsl:call-template name="tag">
<xsl:with-param name="name">$.Result.LastName</xsl:with-param>
<xsl:with-param name="value"><xsl:value-of select="./LastName"
/></xsl:with-param>
</xsl:call-template>

<xsl:call-template name="tag">
<xsl:with-param name="name">$.Result.Extension</xsl:with-param>
<xsl:with-param name="value"><xsl:value-of select="./Extension"
/></xsl:with-param>
</xsl:call-template>

<xsl:call-template name="tag">
<xsl:with-param name="name">$.Result.Department</xsl:with-param>
<xsl:with-param name="value"><xsl:value-of select="./Department"
/></xsl:with-param>
</xsl:call-template>
</xsl:element>
</xsl:template>

</xsl:stylesheet>

As you can see, there are some part that are commented becuase they
don't work.

Cheers!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
In article <3f***********************@news.frii.net>,
Julio Kriger <jk*****@hotpop.com> wrote:

% Hi, I supose if I try what you say it will work. However, I only need
% the attribute
% 'xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"
% ' to say to the grammar compiler to use some extension to build the
% binary file of the grammar.

This sounds like a misuse of the name space declaration.

% Now I have it working with the following xslt, but I beleive it's a
% workaround and not a good solution:

I'm not sure what your problem is. Do you mean you would rather have
<xsl:element name='grammar'>
...

rather than
<grammar ...>

?

Blech. In my opinion, you should never use xsl:element or xsl:attribute
unless you need to generate the names dynamically. It makes the
stylesheet about a hundred times harder to read when you do.

If it's not that, then what's the problem?
--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #6
Hi,
I would rather user <xsl:element name='grammar'> than <grammar ...>
I beleive it's more properly done this way (<xsl:element
name='grammar'>) than the other way (<grammar ...>).
Maybe it's a really misuse of namespace declaration. I don't know.
I have created a C# program that create this kind of grammar files, with
the use of createelement and createattibute of the xmldocument object. I
thouht it will be same with XSLT.
Cheers!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #7
In article <3f***********************@news.frii.net>,
Julio Kriger <jk*****@hotpop.com> wrote:

% I would rather user <xsl:element name='grammar'> than <grammar ...>
% I beleive it's more properly done this way (<xsl:element
% name='grammar'>) than the other way (<grammar ...>).

Just get that idea out of your head. I mean, do it if you want, but
don't imagine it's more proper. To me, it's harder to read, harder
to maintain and just generally worse in every way imaginable.

Having said that, if you control the semantics behind this use of
xmlns:whatever, then change the way you do things. Create an attribute
in your own name space which tells your code to do whatever it is
you need to do, rather than depending on a particular name space
declaration being present.
--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #8

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

Similar topics

4
by: James | last post by:
I have a from with 2 fields: Company & Name Depening which is completed, one of the following queries will be run: if($Company){ $query = "Select C* From tblsample Where ID = $Company...
5
by: Scott D | last post by:
I am trying to check and see if a field is posted or not, if not posted then assign $location which is a session variable to $location_other. If it is posted then just assign it to...
2
by: Nick | last post by:
Can someone please tell me how to access elements from a multiple selection list? From what ive read on other posts, this is correct. I keep getting an "Undefined variable" error though... Form...
2
by: Alexander Ross | last post by:
I have a variable ($x) that can have 50 different (string) values. I want to check for 7 of those values and do something based on it ... as I see it I have 2 options: 1) if (($x=="one") ||...
0
by: Dan Foley | last post by:
This script runs fine, but I'd like to know why it's so slow.. Thanks for any help out there on how i can make it faster (it might take up to 5 min to write these 3 export files whith 15 records...
5
by: Lee Redeem | last post by:
Hi there I've created abd uploaded this basic PHP script: <html> <head> <title>PHP Test</title> </head> <body> <H1 align="center">
5
by: christopher vogt | last post by:
Hi, i'm wondering if there is something like $this-> to call a method inside another method of the same class without using the classname in front. I actually use class TEST { function...
6
by: Phil Powell | last post by:
Ok guys, here we go again! SELECT s.nnet_produkt_storrelse_navn FROM nnet_produkt_storrelse s, nnet_produkt_varegruppe v, nnet_storrelse_varegruppe_assoc sv, nnet_produkt p WHERE...
1
by: Michel | last post by:
a site like this http://www.dvdzone2.com/dvd Can you make it in PHP and MySQL within 6 weeks? If so, send me your price 2 a r a (at) p a n d o r a . b e
11
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in...
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
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
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,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.