473,769 Members | 2,331 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using default attribute value

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I've some namespace problems when defining default values for attributes.

My problem seems to come from the fact that the attributes are defined in a
different namespace from the element.

I've defined the XLink attributes in xlink.xsd. (I've copied just a subset)
I've written a personal schema defining elements in an other namespace in
schema.xsd. I defined default values for some XLink attributes.
But, when I process doc.xml,
the element

<link xl:href="http://www.google.fr"> Google</link>

becomes

<link xl:href="http://www.google.fr" show="new" actuate="onRequ est"
type="simple">G oogle</link>

But I expected:

<link xl:href="http://www.google.fr" xl:show="new" xl:actuate="onR equest"
xl:type="simple ">Google</link>

I don't understand why the XML processor (Xerces in my case) deletes the xl
namespace prefix.
Note, that the processed file is not valid any more !!!
As a consequence, Mozilla doesn't interpret this link node as an hypertext
node. :-(

How can I do in order to define default values for attributes that are
defined in a different namespace from the elements ??

Thanks for any help !
Lénaïc.
doc.xml <<<
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="copy.xsl" ?>
<root xmlns="http://MySchema"
xmlns:xl="http://www.w3.org/1999/xlink"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://MySchema schema.xsd">
<link xl:href="http://www.google.fr"> Google</link>
<link xl:href="http://www.w3.org">W3C </link>
<link xl:type="simple " xl:href="http://www.xmlfr.org" xl:show="new"
xl:actuate="onR equest">XML</link>
</root>
end of doc.xml <<< processed doc.xml <<<
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl" ?>

<root xmlns="http://MySchema" xmlns:xl="http://www.w3.org/1999/xlink"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://MySchema schema.xsd">
<link xl:href="http://www.google.fr" show="new" actuate="onRequ est"
type="simple">G oogle</link>
<link xl:href="http://www.w3.org" show="new" actuate="onRequ est"
type="simple">W 3C</link>
<link xl:type="simple " xl:href="http://www.xmlfr.org" xl:show="new"
xl:actuate="onR equest">XML</link>
</root>
end of processed doc.xml <<< xlink.xsd <<<
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN"
"http://www.w3.org/2001/XMLSchema.dtd">

<xs:schema xmlns="http://www.w3.org/1999/xlink"
xmlns:xl="http://www.w3.org/1999/xlink"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace ="http://www.w3.org/1999/xlink"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d">

<xs:attribute name="type">
<xs:simpleTyp e>
<xs:restricti on base="xs:NMTOKE N">
<xs:enumerati on value="simple" />
<xs:enumerati on value="extended " />
<xs:enumerati on value="locator" />
<xs:enumerati on value="arc" />
<xs:enumerati on value="resource " />
<xs:enumerati on value="title" />
<xs:enumerati on value="none" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>

<xs:attribute name="href" type="xs:anyURI " />

<xs:attribute name="show">
<xs:simpleTyp e>
<xs:restricti on base="xs:NMTOKE N">
<xs:enumerati on value="new" />
<xs:enumerati on value="replace" />
<xs:enumerati on value="embed" />
<xs:enumerati on value="other" />
<xs:enumerati on value="none" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>

<xs:attribute name="actuate">
<xs:simpleTyp e>
<xs:restricti on base="xs:NMTOKE N">
<xs:enumerati on value="onLoad" />
<xs:enumerati on value="onReques t" />
<xs:enumerati on value="other" />
<xs:enumerati on value="none" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>

<xs:attribute name="label" type="xs:NCName " />

<xs:attribute name="from" type="xs:NCName " />

<xs:attribute name="to" type="xs:NCName " />
<xs:attributeGr oup name="simpleLin k">
<xs:attribute ref="xl:type" fixed="simple" />
<xs:attribute ref="xl:href" use="optional" />
<xs:attribute ref="xl:show" use="optional" />
<xs:attribute ref="xl:actuate " use="optional" />
</xs:attributeGro up>

</xs:schema>
end of xlink.xsd <<< schema.xsd <<<
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN"
"http://www.w3.org/2001/XMLSchema.dtd">

<xs:schema xmlns="http://MySchema"
xmlns:my="http://MySchema"
xmlns:xl="http://www.w3.org/1999/xlink"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace ="http://MySchema"
elementFormDefa ult="qualified"
attributeFormDe fault="unqualif ied">
<xs:import namespace="http ://www.w3.org/1999/xlink"
schemaLocation= "xlink.xsd" />

<xs:element name="root" type="my:rootTy pe" />

<xs:complexTy pe name="rootType" >
<xs:sequence>
<xs:element name="link" type="my:linkDe faultType"
maxOccurs="unbo unded" />
</xs:sequence>
</xs:complexType>

<xs:complexTy pe name="linkBaseT ype">
<xs:simpleConte nt>
<xs:extension base="xs:string ">
<xs:attributeGr oup ref="xl:simpleL ink" />
</xs:extension>
</xs:simpleConten t>
</xs:complexType>

<xs:complexTy pe name="linkDefau ltType">
<xs:simpleConte nt>
<xs:restricti on base="my:linkBa seType">
<xs:attribute ref="xl:show" default="new" />
<xs:attribute ref="xl:actuate " default="onRequ est" />
</xs:restriction>
</xs:simpleConten t>
</xs:complexType>

</xs:schema>
end of schema.xsd <<<

- --
(o_ Lénaïc HUARD
//\ Le**********@la poste.net
V_/_ KeyID: 0x04D2E818
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBMMPBjYE jJATS6BgRAuA2AJ 4t+lz0R8CeGN9XZ XWUdh+qlWHpSwCg n4F7
TzhlOG7NXMguHDy Dm753Tns=
=EfcB
-----END PGP SIGNATURE-----
Jul 20 '05 #1
4 2935
Lénaïc Huard wrote:
But, when I process doc.xml,
the element

<link xl:href="http://www.google.fr"> Google</link>

becomes

<link xl:href="http://www.google.fr" show="new" actuate="onRequ est"
type="simple">G oogle</link>


Your document references an XSL stylesheet copy.xsl. How do you process
the document?

--
Klaus Johannes Rusch
Kl********@atme dia.net
http://www.atmedia.net/KlausRusch/
Jul 20 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Klaus Johannes Rusch wrote:
Lénaïc Huard wrote:
But, when I process doc.xml,
the element

<link xl:href="http://www.google.fr"> Google</link>

becomes

<link xl:href="http://www.google.fr" show="new" actuate="onRequ est"
type="simple">G oogle</link>


Your document references an XSL stylesheet copy.xsl. How do you process
the document?


In fact, I needed a stylesheet in order to see it with Mozilla (without
stylesheet, Mozilla displays the tree). And in order to see how the default
attributes are imported by an Xml processor, I used Xalan.

That's the reasons why I use a stylesheet which does nothing. (Or should
does nothing but copying the source tree without any modification... )
copy.xsl <<<
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml"
indent="yes"
encoding="ISO-8859-1" />

<xsl:template match="/">
<xsl:copy-of select="." />
</xsl:template>

</xsl:stylesheet>
end of copy.xsl <<<

- --
(o_ Lénaïc HUARD
//\ Le**********@la poste.net
V_/_ KeyID: 0x04D2E818

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBMP4wjYE jJATS6BgRAkPuAJ 9pIZEOkVIIHy+nw cq9PXYVmcxOQQCg gU4k
g0eOzqck+XyTKj0 EagZjqq0=
=uE4M
-----END PGP SIGNATURE-----
Jul 20 '05 #3
In article <41************ ***********@new s.free.fr>,
Lénaïc Huard <le**********@l aposte.net> wrote:
I don't understand why the XML processor (Xerces in my case) deletes the xl
namespace prefix.


I think it must be a bug in the Xerces schema validator, or whatever
you are using the serialize the schema-validated document.

-- Richard
Jul 20 '05 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Richard Tobin a écrit:
In article <41************ ***********@new s.free.fr>,
Lénaïc Huard <le**********@l aposte.net> wrote:
I don't understand why the XML processor (Xerces in my case) deletes the
xl namespace prefix.


I think it must be a bug in the Xerces schema validator, or whatever
you are using the serialize the schema-validated document.


Well ! Let's try another XML parser ! ;-)

I tried xmllint ; but it seems to compil the Schema not as I expected :

The lines

<link xl:href="http://www.google.fr"> Google</link>
<link xl:href="http://www.w3.org">W3C </link>
<link xl:type="simple " xl:href="http://www.xmlfr.org" xl:show="new"
xl:actuate="onR equest">XML</link>

produces the following errors:

doc.xml:10: element link: Schemas validity error : Character or element
children are not allowed, because the content type is empty.

These errors don't appear with Xerces (through Xalan)

As a reminder : here is how the link element is defined :
schema.xsd extract <<<
<xs:element name="link" type="my:linkDe faultType" />

<xs:complexTy pe name="linkBaseT ype">
<xs:simpleConte nt>
<xs:extension base="xs:string ">
<xs:attributeGr oup ref="xl:simpleL ink" />
</xs:extension>
</xs:simpleConten t>
</xs:complexType>

<xs:complexTy pe name="linkDefau ltType">
<xs:simpleConte nt>
<xs:restricti on base="my:linkBa seType">
<xs:attribute ref="xl:show" default="new" />
<xs:attribute ref="xl:actuate " default="onRequ est" />
</xs:restriction>
</xs:simpleConten t>
</xs:complexType>
end of schema.xsd extract <<<


The linkBaseType is not designed to be used (I should put abstract="true" ).
But I need it to define default values for some attributes.
If I put the <xs:attribute ref="xl:show" default="new" /> element inside the
linkBaseType definition, the XML parser complains that xl:show attribute is
defined twice in the type. That's the reason why I used a derivation.

In the derivation, I don't remind that the content of the element is a
xs:string. Xerces considers that the content is unchanged whereas xmllint
considers that the content of the derived type is empty.

Which is right and how to enforce the fact that the content of the derived
type is still an xs:string ?

Lénaïc.
- --
(o_ Lénaïc HUARD
//\ Le**********@la poste.net
V_/_ KeyID: 0x04D2E818

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBMdSPjYE jJATS6BgRAp53AK CigWv9SsJ4rvnwo HTOgngboo2t7ACf U74x
6jwpMXbzzugXiJp U/EqmwaI=
=bfqq
-----END PGP SIGNATURE-----
Jul 20 '05 #5

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

Similar topics

2
2039
by: Gabriel Genellina | last post by:
Hi In the following code sample, I have: - a Worker class, which could have a lot of methods and attributes. In particular, it has a 'bar' attribute. This class can be modified as needed. - a Base class (old-style) which defines a default class attribute 'bar' too. I can't modify the source code of this class. Note that Workes does not inherit from Base. - a Derived class which must inherit from Base and is a wrapper around Worker: it...
3
2350
by: Michael Ahlers | last post by:
Obviously if you're looping or using a template, choosing output based on the current iteration is easy. For example, if you're walking a set of elements and you want index % 2 == 0 produce one thing and another when that is not true. My question is, what if you are not looping through tags but want to achieve a similar effect without having to be excessively verbose? Is there any way that I can simplify the following block? <!-- ......
11
6600
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
1
1849
by: Asha | last post by:
greetings, i need to upload an .xls file using a secure connection. so i though of using https... can i know how this can be done?
44
2770
by: gregory.petrosyan | last post by:
Hello everybody! I have little problem: class A: def __init__(self, n): self.data = n def f(self, x = ????) print x All I want is to make self.data the default argument for self.f(). (I
2
1602
by: Nicolas | last post by:
Hi everybody... In Xerces 2.7.0 it is explicitly stated that, no matter how one removes an attribute (attList->removeNamedItem, attList->removeNamedItemNS, domElement->removeAttributeNode, domElement->removeAttribute, domElement->removeAttributeNS), if that attribute has a default value it is immediately replaced. However I cannot obtain that behaviour...
0
25598
ADezii
by: ADezii | last post by:
The motivation for this Tip was a question asked by one of our Resident Experts, FishVal. The question was: How to Declare Default Method/Property in a Class Module? My response to the question was inadequate to say the least, but I was determined to come up with the correct answer, especially since my primary background is Visual Basic, and I knew that there was an answer. Well, I did come up with an answer and I decided to incorporate it into...
7
3023
by: Anz | last post by:
I used the javascript functions as shown below. <a href="javascript:;;;" onclick="this.style.behavior='url(#default#homepage)'; this.setHomePage(location.href);"> But this code works for IE, not for Firefox. While running this code, the firefox shows javascript error as this.setHomePage is not a function
2
8760
by: Nathan Sokalski | last post by:
I am attempting to create icons for controls I have created using VB.NET by using the System.Drawing.ToolboxBitmap attribute. I have managed to do this in C# by specifying the path to the *.ico file, but I have been unable to get any of the overloads to work in VB.NET. I would like to store the *.ico files in a *.resx file so that users do not need anything other than the *.dll, but at the moment I am just trying to get any of the overloads...
0
9589
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...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
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
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
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
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.