473,795 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transparent XML Tags?

If I have a well-formed XML document, can I somehow tell a validating parser
to ignore selected tags? I want these tags to be ignored for validation
purposes, bit I still want to validate the contents of these tags based on
the rules applicable to their parent tags.

For example, if my schema looks something like this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Parent">
<xs:complexType >
<xs:sequence>
<xs:element name="Child">
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Child"/>
<xs:element name="Transpare ntTag"/>
<xs:element name="SomeOther Tag"/>
</xs:schema>

I would like this to be valid:

<Parent>
<TransparentTag ><Child>Jim</Child></TransparentTag>
</Parent>

But not this:

<Parent>
<SomeOtherTag>< Child>Jim</Child></SomeOtherTag>
</Parent>

or this:

<Parent>
<TransparentTag ><Sibling>Luc y</Sibling></TransparentTag>
</Parent>

We have enough of these types of tags, like TransparentTag, that spelling
out all the possible combinations in my schema would be impractical, and
would make our schema extremely large. We could possibly use a really loose
schema. For example, we could allow a "Parent" tag to have either a "Child"
tag or a "TransparentTag ", or both types of tag, and then we could allow a
"TransparentTag " to hold any other tag. But we would prefer a stricter
schema, if possible.

Using <any> doesn't seem to help, because this allows any tag from, say, a
given namespace, but then it doesn't validate the contents of this tag based
on rules applying to the parent tag.

Any suggestion or ideas would be much appreciated. Also, I apologize if my
previous posting on this topic was not clear.

Thank you.

Jim Whitehead
Jul 20 '05 #1
4 3058
Jim Whitehead <Ja************ ***@ksc.nasa.go v> wrote:
: I would like this to be valid:
:
: <Parent>
: <TransparentTag ><Child>Jim</Child></TransparentTag>
: </Parent>
:
: But not this:
:
: <Parent>
: <SomeOtherTag>< Child>Jim</Child></SomeOtherTag>
: </Parent>

Hi Jim,

As to these cases, perhaps you could first make all of
TransparentTag, SomeOtherTag, etc valid and then apply a
tranformation as a filter that would remove the TranparentTag
wrappers and invalid nested child elements?

Or, to make specifying all cases somewhat more practical, maybe you can
more comfortably write a suitable SGML DTD and have that transformed
into a Schema? Like so:

<!ENTITY % Good "TransparentTag " -- may have child elements -->

<!ENTITY % Bad "(SomeOther Tag | YetAnotherTag)"
-- These elements must not have content -- >

<!ELEMENT Parent - - (%Good; | %Bad;)* >

<!ELEMENT %Good; - - (Child)>
<!ELEMENT %Bad; - - EMPTY>

<!ELEMENT Child - - (#PCDATA)>
Georg Bauhaus
Jul 20 '05 #2

"Georg Bauhaus" <sb*****@d2-hrz.uni-duisburg.de> wrote in message
news:bi******** **@a1-hrz.uni-duisburg.de...

As to these cases, perhaps you could first make all of
TransparentTag, SomeOtherTag, etc valid and then apply a
tranformation as a filter that would remove the TranparentTag
wrappers and invalid nested child elements?
Thank you very much for the suggestion. The trouble is that I don't want to
remove the TranparentTags, because we have an application that needs to use
them. I guess we could remove the TranparentTags for validation purposes,
but then use the original, non-transformed document for our internal
purposes. It would seem we might then want to have two Schemas, one
pre-Transformation and one post-Transformation. ..
Or, to make specifying all cases somewhat more practical, maybe you can
more comfortably write a suitable SGML DTD and have that transformed
into a Schema? Like so:

<!ENTITY % Good "TransparentTag " -- may have child elements -->

<!ENTITY % Bad "(SomeOther Tag | YetAnotherTag)"
-- These elements must not have content -- >

<!ELEMENT Parent - - (%Good; | %Bad;)* >

<!ELEMENT %Good; - - (Child)>
<!ELEMENT %Bad; - - EMPTY>

<!ELEMENT Child - - (#PCDATA)>


I will have to spend some time with this SGML DTD idea before I can say if
it will work for us. Are you suggesting that we automatically generate the
XML schema from an SGML DTD because the SGML DTD allows more flexibility in
specifying validation rules (and so we can simplify the creation of the XML
Schema)? Thanks again!


Jul 20 '05 #3
Jim Whitehead <Ja************ ***@ksc.nasa.go v> wrote:
: I guess we could remove the TranparentTags for validation purposes,
: but then use the original, non-transformed document for our internal
: purposes. It would seem we might then want to have two Schemas, one
: pre-Transformation and one post-Transformation. ..

: I will have to spend some time with this SGML DTD idea before I can say if
: it will work for us. Are you suggesting that we automatically generate the
: XML schema from an SGML DTD because the SGML DTD allows more flexibility in
: specifying validation rules (and so we can simplify the creation of the XML
: Schema)? Thanks again!

Yes that is what I have had in mind. However, I can't for the life of
me remember what software I have seen that can do the transformation
automatically (to the extent that a grammar transformation is
possible?) So that might turn out to be less helpful than I had thought.

But maybe another idea works. Given a Schema, you transform that schema
into another one that describes the difference in the presence
of tags. Here is a hypothetical Schema and a transformation the will
remove the wrapping tags AnotherTag and YetAnotherTag from Parent's
content model. (I don't speak Schema well, so there might be errors...)
<xsd:schema version='1.0'
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
targetNamespace ="file:hide.xsd "
xmlns:e="file:h ide.xsd">

<xsd:element name="Parent" type="e:ParentC M"/>

<xsd:complexTyp e name="ParentCM" >
<xsd:choice>
<xsd:element ref="e:Transpar entTag"/>
<xsd:element ref="e:SomeOthe rTag"/>
<xsd:element ref="e:YetAnoth erTag"/>
</xsd:choice>
</xsd:complexType >
<xsd:complexTyp e name="ChildCM">
<xsd:sequence >
<xsd:element ref="e:Child"/>
</xsd:sequence>
</xsd:complexType >

<xsd:element name="Child" type="string"/>

<xsd:element name="Transpare ntTag" type="e:ChildCM "/>
<xsd:element name="AnotherTa g" type="e:ChildCM "/>
<xsd:element name="YetAnothe rTag" type="e:ChildCM "/>

</xsd:schema>

Now the transformation:
<stylesheet
version='1.0'
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:e="file:h ide.xsd"


<template match="/">
<apply-templates/>
</template>

<!--
Replace every reference to not(Transparent Tag) with just
a reference to a Child
-->
<template match="xsd:elem ent[@ref='e:SomeOth erTag' or
@ref='e:YetAnot herTag']">
<xsd:element ref="e:Child"/>
</template>

<!-- everything else is unchanged -->
<template match="node() | @*">
<copy>
<apply-templates select="node() | @*"/>
</copy>
</template>

</stylesheet>

The output Schema then contains
<xsd:complexTyp e name="ParentCM" >
<xsd:choice>
<xsd:element ref="e:Transpar entTag"/>
<xsd:element ref="e:Child"/>
<xsd:element ref="e:Child"/>
</xsd:choice>
</xsd:complexType >
Georg
Jul 20 '05 #4
Thank you very much, Georg. You have provided me with much good food for
thought.

Jim
Jul 20 '05 #5

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

Similar topics

0
1431
by: CJM | last post by:
I'm working through Eric Meyer on CSS (a good book). In one example, he uses the following styles: a:link, a:visited { background-color: Transparent; font-weight:bold; } a:link {
7
27555
by: Thomas Wieser | last post by:
Hi, my problem: I have some tables with transparent backgrounds, which are changed in colours within a JavaScript DOM function to have a roll-over effect. Now, i can't get them back transparent when leaving the mouse out of the rollover-box - background-color: none; seems not to work. Isn't it possible to do this with CSS?
1
20184
by: Efkas | last post by:
My application have some level : 1. MyButton class with Label inheritance 2. MyComponent as User Control loading and positionning some of MyButtons 3. MyApp loading and positionning MyComponent I prefer don't insert a background in MyComponent, and using the MyApp one as general background with MyComponent positionned, but I am not able to have MyComponent background transparent.
3
3107
by: Steve Koon | last post by:
Any thoughts on getting this project to work or suggesting another method would be appreciated. Steve ========================================== Project: A Windows Form which acts as a Whiteboard. The Form contains 3
7
3591
by: Peter Oliphant | last post by:
Using MakeTransparent one can supposedly turn a color used in a Bitmap to transparent. But, it looks to me like all it does it set these pixels to the color BackColor of the Control it's attached to. Thus, when I set White to the transparent color of a Bitmap stored in the Image of a PictureBox and placed the PictureBox on a Form which has a BackColor of black, it turned the white pixels of the bitmap image to black, but these black pixels...
4
2565
by: jcrouse | last post by:
I am using the following code to move a label on a form at runtime: If myMousedown = lblP1JoyRight.Name Then If lblP1JoyRight.BackColor.Equals(Color.Transparent) Then bTransCk = True lblP1JoyRight.BackColor = clrLabelMove
5
1327
by: NEWS | last post by:
if I want to change a tag with CSS with a file rather than having all the CSS code on the HTML doc I know I can do the following <SNIPPET> body.Wyght { background-color: #D9D9FF; border: 50px; border-color: #A000B2; font-family: cursive;
4
9376
by: ray well | last post by:
in my app i need to make a RichTextbox control transparent. i need it to be a like a pane of glass lying on a sheet of paper, where u can see everything on the sheet of paper not covered by text written on the glass pane. i need to be able to see the control or form that is underneath the RichTextbox, and at the same time to be able to write and erase text to the RichTextbox. i'm assuming that it is the backcolor that hides what is...
8
5139
by: azjudd | last post by:
Thank you in advance for your help on this one. I'm using named anchor tags on a FAQ page with questions listed at the top and answers below; a standard jump-to feature. However, anytime an anchor tag link is used, whether it be a question down to an answer or an answer back to the list of questions, I lose the banner div, a good portion of of my MenuDv disappears, and white space is added to the bottom of my page. You can see my FAQ page...
0
10443
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
10216
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
10165
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
6783
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
5437
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
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
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.