CSS select previous sibling
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 23
- Joined: Sat Mar 08, 2014 12:10 am
CSS select previous sibling
Hi,
My CSS looks like this:
My XML looks like this:
The expected output is:
North America|Canada|British Columbia|Whistler
Does anyone see why this doesn't work.
THANKS
My CSS looks like this:
Code: Select all
CITY + NEIGHBORHOOD[name=""] {
display:inline;
font-style:italic;
content: oxy_xpath("//CITY/@name");
}
Code: Select all
<LISTING>
<COUNTRY geo_id="0" id="1051" name="Canada"/>
<STATE geo_id="0" id="48999" name="North America|Canada|British Columbia"/>
<CITY geo_id="0" id="5503" name="North America|Canada|British Columbia|Whistler"></CITY>
<NEIGHBORHOOD geo_id="" id="0" name=""/>
</LISTING>
North America|Canada|British Columbia|Whistler
Does anyone see why this doesn't work.
THANKS
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: CSS select previous sibling
Post by alex_jitianu »
Hi,
I tested the samples you provided and in my case the author mode presented just what you've expected : North America|Canada|British Columbia|Whistler. Perhaps there is a StylesFilter involved and it also changes the styles of the element? If not, what Oxygen version you are using? If you test these samples in a fresh Oxygen installation (one that has just the default frameworks) are they working as expected?
Best regards,
Alex
I tested the samples you provided and in my case the author mode presented just what you've expected : North America|Canada|British Columbia|Whistler. Perhaps there is a StylesFilter involved and it also changes the styles of the element? If not, what Oxygen version you are using? If you test these samples in a fresh Oxygen installation (one that has just the default frameworks) are they working as expected?
Best regards,
Alex
-
- Posts: 23
- Joined: Sat Mar 08, 2014 12:10 am
Re: CSS select previous sibling
There is a StyleFilter and DocumentModificationFilter (setAttribute) in play.
If CITY and NEIGBORHOOD are in LISTING, they are form controls. If they are a chapter, I render them as normal text. Everything seems to work but the xpath with the attribte that doesnt work.
My StyleFilter code is:
My CSS is attempting th following: (1) If NEIGHBORBHOOD/@name is empty or does not exist, print CITY/@name, (2)Otherwise print NEIGHBORHOOD/@name.
What I did notice is that if I use oxy_xpath("//CITY/text()"), I do get the text. So it appears to be the name attribute. I will try to run this down in the DocumentModificationsFilter.
Thanks for your help
If CITY and NEIGBORHOOD are in LISTING, they are form controls. If they are a chapter, I render them as normal text. Everything seems to work but the xpath with the attribte that doesnt work.
My StyleFilter code is:
Code: Select all
else if (authorNode.getName().equals("CITY")) {
// getOwnerDocument returns null when part of DocumentFrgement
// This is what crashes [+ City] action
AuthorNode authorDocument = authorNode.getOwnerDocument();
if (authorDocument != null) {
AuthorElement rootElement = authorNode.getOwnerDocument().getRootElement();
if (rootElement.getName().equals("LISTING")) {
EditorContent editorContent = geosBuilder.getEditorContent("city");
styles.setProperty(Styles.KEY_MIXED_CONTENT, new StaticContent[] {editorContent});
returnAlteredStyles = true;
}
}
}
else if (authorNode.getName().equals("NEIGHBORHOOD")) {
// getOwnerDocument returns null when part of DocumentFrgement
// This is what crashes [+ Hood] action
AuthorNode authorDocument = authorNode.getOwnerDocument();
if (authorDocument != null) {
AuthorElement rootElement = authorNode.getOwnerDocument().getRootElement();
if (rootElement.getName().equals("LISTING")) {
EditorContent editorContent = geosBuilder.getEditorContent("hood");
styles.setProperty(Styles.KEY_MIXED_CONTENT, new StaticContent[] {editorContent});
returnAlteredStyles = true;
}
}
}
Code: Select all
/*DOES NOT WORK/
CITY + NEIGHBORHOOD[name=""] {
display:inline;
font-style:italic;
content: ", " oxy_xpath("//CITY/@name");
}
/*WORKS*/
CITY + NEIGHBORHOOD[name*="|"] {
display:inline;
font-style:italic;
content: ", " oxy_substring(attr(name), oxy_add(oxy_lastindexof(attr(name), '|'), 1, integer));
}
/*WORKS*/
CITY + NEIGHBORHOOD[name] {
display:inline;
font-style:italic;
content: ", " oxy_substring(attr(name), oxy_add(oxy_lastindexof(attr(name), '|'), 1, integer));
}
Thanks for your help
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: CSS select previous sibling
Post by alex_jitianu »
Hi Deanna,
The code below, changes the content property in the styles. This is the same property on which you put the oxy_xpath() on. The StylesFilter is applied last so it will override the rule from the CSS.
You should probably add some checks in the StylesFilter to only change the content property of NEIGHBORBHOOD so that it doesn't overlap with the CSS rules. It's strange that oxy_xpath("//CITY/text()") works, because from the StylesFilter code looks like it always overrides the content of NEIGHBORBHOOD.
Best regards,
Alex
The code below, changes the content property in the styles. This is the same property on which you put the oxy_xpath() on. The StylesFilter is applied last so it will override the rule from the CSS.
Code: Select all
else if (authorNode.getName().equals("NEIGHBORHOOD")) {
// getOwnerDocument returns null when part of DocumentFrgement
// This is what crashes [+ Hood] action
AuthorNode authorDocument = authorNode.getOwnerDocument();
if (authorDocument != null) {
AuthorElement rootElement = authorNode.getOwnerDocument().getRootElement();
if (rootElement.getName().equals("LISTING")) {
EditorContent editorContent = geosBuilder.getEditorContent("hood");
styles.setProperty(Styles.KEY_MIXED_CONTENT, new StaticContent[] {editorContent});
returnAlteredStyles = true;
}
}
}
Best regards,
Alex
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service