XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] CSS selectors are syntactic sugar for XPath expressions

I, um, don't think you've met many CSS developers?  Selectors came first, and there are definitely selectors without XPath equivalents.

There's a Venn diagram with a big overlap, but wow the separations are important.  I don't think that what you want to do with CSS is in the overlap zone.

Thanks,
Simon


On 3/21/2022 1:58 PM, Roger L Costello wrote:
Hi Folks,

Recall that CSS rules consist of two parts: a selector and styling statements. For example, this rule says the content of the <h1> element is to be italicized:

h1 { font-style: italic; }

Multiple elements can be identified in a rule by separating their names with commas, e.g.,

h1, h2, h3  { font-style: italic; }

That is equivalent to these three rules:

h1 { font-style: italic; }
h2 { font-style: italic; }
h3 { font-style: italic; }

Both forms say this: Italicize the content of h1 headers; italicize the content of h2 headers; and italicize the content of h3 headers. The styling actions on h1, h2, and h3 are independent of one another.

The CSS selectors are syntactic sugar (convenient shorthand notations) for equivalent XPath expressions. For example:

div  		//div
h1 em  		//h1//em
.title   		//*[@class='title']
#mars    	//*[@id='mars']
div#mars 	//div[@id='mars']

CSS selectors are really nice. They are simple and powerful.

I would like to use the "CSS approach" for a language that I am creating. But there is a problem. Suppose the language that I am creating is to operate on this XML:

<person>
   <name>John Doe</name>
   <telephone>555-123-4567</telephone>
   <latitude>42.366978</latitude>
   <longitude>-71.022362</longitude>
</person>

The latitude/longitude pair corresponds to the location of Logan airport in Boston. So the XML document shows John Doe at Logan airport. I would like a rule that fuzzes the latitude and longitude elements so that you only know John Doe's location to within a 10 kilometer radius of Boston. One might imagine a rule like this:

latitude, longitude { fuzz_location(...); }

However, the semantics of CSS says that that rule is equivalent to two independent rules:

latitude		{ fuzz_location(...); }
longitude 	{ fuzz_location(...); }

That's not what I want. The latitude and longitude values are intertwined; their values must be operated on together, not independently.

I want to avoid using the XPath syntax for selectors, as XPath is too complex for my users.

I want to use the simple CSS syntax, but somehow I need to extend its semantics so that a rule can select a set of elements that are operated on together. Have you done this type of thing -- extended the CSS semantics so that a selected set of elements are operated on together?

/Roger

_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS